我在 AngularJS( ionic 框架)中有一个应用程序,在 Symfony 中有一个服务器。
在本地一切正常,但现在我使用在线服务器进行测试。不幸的是,一切都不像本地那样发生,我有以下错误:
No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http: // localhost' is therefore not allowed access.
我想知道如何添加缺少的“Access-Control-Allow-Origin”CORS header 。
最佳答案
使用这个包:NelmioCorsBundle
CORS-Bundle 用于定义 CORS 规则。该 bundle 允许您定义哪些域可以访问您的 REST API。它也会让你的工作更轻松 :)
关于angularjs - 请求的资源上不存在 'Access-Control-Allow-Origin' header 。因此不允许访问 Origin 'http://localhost',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43677015/