0%

vue axios tp5错误

文章字数:100,阅读全文大约需要1分钟

已拦截跨源请求:同源策略禁止读取位于 http://101.132.138.141:8888/service/pageUsers 的远程资源。(原因:CORS 头缺少 ‘Access-Control-Allow-Origin’)。

axios跨域带上cookie,axios session消失

vue的main.js 加上axios.defaults.withCredentials = true;

解决方法

withCredentials的情况下,后端要设置Access-Control-Allow-Origin为你的源地址,例如http://localhost:8080,不能是*,而且还要设置header(‘Access-Control-Allow-Credentials: true’);