Commit 2a8508d6 authored by zhouzihao's avatar zhouzihao

dev-允许跨域请求

parent 7fd4a0a9
......@@ -13,6 +13,16 @@ app.use(bodyParser.urlencoded({ // to support URL-encoded bodies
extended: true
}));
// 允许跨域请求
app.all('*', function (req, res, next) {
res.header('Access-Control-Allow-Origin', '*');
//Access-Control-Allow-Headers ,可根据浏览器的F12查看,把对应的粘贴在这里就行
res.header('Access-Control-Allow-Headers', 'Content-Type');
res.header('Access-Control-Allow-Methods', '*');
res.header('Content-Type', 'application/json;charset=utf-8');
next();
});
// todo add route
// test api
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment