CORS express not working predictably

前端 未结 6 1024
灰色年华
灰色年华 2021-02-08 08:15

I am trying to allow access from everywhere.

I have tried using app middleware:

app.use(function (req, res, next) {
  res.setHeader(\"Access-Control-Allo         


        
6条回答
  •  清酒与你
    2021-02-08 08:44

    Following other's answers, this worked for me:

    res.setHeader("Access-Control-Allow-Origin", 'http://myDomain:8080');
    res.setHeader('Access-Control-Allow-Methods', 'POST,GET,OPTIONS,PUT,DELETE');
    res.setHeader('Access-Control-Allow-Headers', 'Content-Type,Accept');
    

提交回复
热议问题