Ajax post response from express js keeps throwing error

后端 未结 2 1758
再見小時候
再見小時候 2021-01-16 10:27

I am having a real hard time standing up bidirectional data transfer from a html page to my node.js application and then back to the html page.

I\'m pretty sure I\'m

2条回答
  •  不思量自难忘°
    2021-01-16 10:59

    In my case adding this to the app.js works.

    app.use(function(req, res, next) {
      res.header("Access-Control-Allow-Origin", "*");
      res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
      next();
    });
    

    https://enable-cors.org/server_expressjs.html

提交回复
热议问题