CORS: Cannot use wildcard in Access-Control-Allow-Origin when credentials flag is true

后端 未结 9 2507
借酒劲吻你
借酒劲吻你 2020-11-22 01:54

I have a setup involving

Frontend server (Node.js, domain: localhost:3000) <---> Backend (Django, Ajax, domain: localhost:8000)

Browser <-- webapp <

9条回答
  •  旧巷少年郎
    2020-11-22 02:51

    If you want to allow all origins and keep credentials true, this worked for me:

    app.use(cors({
      origin: function(origin, callback){
        return callback(null, true);
      },
      optionsSuccessStatus: 200,
      credentials: true
    }));
    

提交回复
热议问题