vue-admin-html-java icon indicating copy to clipboard operation
vue-admin-html-java copied to clipboard

跨域问题的解决

Open cfrzjj opened this issue 6 years ago • 2 comments

您好,我注释了mock,出现跨域的问题,请问是因为项目中还有什么地方需要改么,还是说我自己在后端处理 Access to XMLHttpRequest at 'http://localhost:9998/admin/auth/login/out' from origin 'http://localhost:8080' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: The 'Access-Control-Allow-Origin' header has a value 'http://localhost:8081' that is not equal to the supplied origin.

所注代码: //update by // import "./mock"; // 模拟数据 还望大佬指教,vue是否可直接在前端文件中解决该问题?

cfrzjj avatar Aug 24 '19 08:08 cfrzjj

楼主,已解决,您的文件中部分代码应需要改8081 为8080 后端 application-dev.properties文件

跨域设置

cors.allowed-origins=http://localhost:8080 #cors.allowed-origins=http://localhost:8081

cfrzjj avatar Aug 24 '19 14:08 cfrzjj

大佬您好,我改了后台cors.allowed-origins = http:// localhost:8080 注释了前端:main.js //import "./mock";跨域问题还是存在,连登陆页面都无法打开

Access to XMLHttpRequest at 'http://localhost:9998/admin/auth/login/out' from origin 'http://127.0.0.1:8080' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: The 'Access-Control-Allow-Origin' header has a value 'http://localhost:8080' that is not equal to the supplied origin.

qujiwen avatar Mar 26 '20 10:03 qujiwen