微信版本导致nodejs+vue3前后端分离的项目出现跨域问题

117 阅读1分钟

重新装机后,项目突然出来错误,无法登陆,点击登陆无法提交到后端,后端无反应,控制台提示:

Access to XMLHttpRequest at 'http://127.0.0.1:8000/api/getUserType' from origin 'http://127.0.0.1:5173' has been blocked by CORS policy: Request header field task-access-token is not allowed by Access-Control-Allow-Headers in preflight response.

The error message you're encountering is a Cross-Origin Resource Sharing (CORS) issue. CORS is a security feature implemented by web browsers to restrict access to resources from different domains. When your JavaScript code running on one origin tries to make an XMLHttpRequest to a different origin, the browser sends a preflight request (OPTIONS method) to check if the server allows such requests.

但是我已经把cors配置成app.use(cors()) ,没有任何限制,还是出错,重启电脑可以偶尔解决,困扰了我一周多的时间,有次,打开微信,项目突然出错,我意识到是不是微信的问题,我把微信关了,项目立马正常,再打开微信,再出错,再关掉,立马好,我找到原因了,是因为微信版本过低,导致的这个问题,想不明白,为什么微信能导致我的项目跨域问题,有大佬能解释下吗?