has been blocked by CORS policy

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了has been blocked by CORS policy相关的知识,希望对你有一定的参考价值。

Error:

前端访问后端时出现如下报错:

Access to XMLHttpRequest at ‘http://localhost:8000/api/slideshow‘ from origin ‘http://localhost:8080‘ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin‘ header is present on the requested resource.

解决

安装 CORS Middleware for Laravel. (fruitcake /laravel-cors)

The laravel-cors package allows you to send Cross-Origin Resource Sharing headers with Laravel middleware configuration.

https://github.com/fruitcake/laravel-cors

以上是关于has been blocked by CORS policy的主要内容,如果未能解决你的问题,请参考以下文章

Access to XMLHttpRequest at 'XXX' from origin 'XX' has been blocked by CORS policy:

has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is

解决[origin 'http://xxx.xxx.com:xxxx' has been blocked by CORS policy: The request client is n

has been blocked by CORS policy: The ‘Access-Control-Allow-Origin‘ header contains multiple values ‘

has been blocked by CORS policy: The ‘Access-Control-Allow-Origin‘ header contains multiple values ‘

ElementUI项目请求SpringBoot后台项目时提示:Access to XMLHttpRequest at **from origin ** has been blocked by CORS