Origin http://localhost is not allowed by Access-Control-Allow-Origin

后端 未结 5 874
臣服心动
臣服心动 2020-12-05 20:29

I\'m trying to do a fetch from backbone.js to my node.js server. However, I get the following error in the console:

Origin http://localhost is not allowed by A

5条回答
  •  情深已故
    2020-12-05 20:48

    If you want everyone to be able to access the Node app, then try using

    res.header('Access-Control-Allow-Origin', "*")
    

    That will allow requests from any origin. The CORS enable site has a lot of information on the different Access-Control-Allow headers and how to use them.

    I you are using Chrome, please look at this bug bug regarding localhost and Access-Control-Allow-Origin. There is another StackOverflow question here that details the issue.

提交回复
热议问题