我正在使用codeigniter和vue.js开发一个Web应用程序。我也使用axios作为路由助手。我在app/src/main.js
中有这个JS文件。
main.js
router.beforeEach((to,from,next)=>{
axios.defaults.headers.common['Authorization'] = localStorage.getItem('token');
next();
});
当我将标头传递到另一个Vue(例如登录名)时,出现错误消息:
Access to XMLHttpRequest at 'http://localhost/app/api/login' from origin 'http://localhost:8080' has been blocked by CORS policy: Request header field authorization is not allowed by Access-Control-Allow-Headers in preflight response.
请帮助我。