app.use((req, res, next) => {
res.header("Access-Control-Allow-Origin", "*");
res.header('Access-Control-Allow-Methods', 'PUT, GET, POST, DELETE, OPTIONS');
res.header("Access-Control-Allow-Headers",
"Content-Type,Content-Length, Authorization, Accept,X-Requested-With,Access-Control-Allow-Origin");
if (req.method === 'OPTIONS') {
res.sendStatus(200)
}else{
next()
}
})
网友评论