Error: Content-Type is not allowed by Access-Control-Allow-Headers

前端 未结 6 1676
旧巷少年郎
旧巷少年郎 2020-12-23 12:20

I am getting this error in Chrome when trying to send an ajax request:

Content-Type is not allowed by Access-Control-Allow-Headers

Everythi

6条回答
  •  时光取名叫无心
    2020-12-23 13:09

    Set up CORS (Cross-site HTTP Requests) in node. For me it looks like the following:

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

提交回复
热议问题