【发布时间】:2018-10-15 04:39:34
【问题描述】:
我正在编写一个 vue 应用程序并使用 Node.js Api。我已经在后端包含了 cors,其他 post 方法效果很好。但是在这条路由中有一个 Nginx 502 Bad Gateway。
chrome控制台报错
Failed to load resource: the server responded with a status of 502 (Bad Gateway)
Failed to load : No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin is therefore not allowed access. The response had HTTP status code 502.
app.js CORS
app.use(function(req, res, next) {
res.setHeader("Access-Control-Allow-Origin","*");
res.setHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept,Authorization");
res.setHeader('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,PATCH,OPTIONS');
res.setHeader("Access-Control-Allow-Credentials", "false")
next();
});
我的 AddPatient 组件和我的 Axios 在 pastebin 上可用
【问题讨论】:
标签: javascript node.js vue.js axios