搞定了,credentials true 情况下 vue客户端需要配置 axios.defaults.withCredentials= true 需要填写指定域名
const corsOptions = {
"origin": "url链接",
"methods": "GET,HEAD,PUT,PATCH,POST,DELETE",
"preflightContinue": false,
"optionsSuccessStatus": 204,
"credentials":true
}
credentials false 情况下 vue客户端需要配置 axios.defaults.withCredentials= false "origin": "*" 可以为通配符
const corsOptions = {
"origin": "*",
"methods": "GET,HEAD,PUT,PATCH,POST,DELETE",
"preflightContinue": false,
"optionsSuccessStatus": 204,
"credentials":false
}
app.use(cors(corsOptions))
或者 app.use(cors())