【发布时间】:2017-07-05 16:52:18
【问题描述】:
我有一个前端 AngularJS 应用程序,它使用用 Symfony 3 编写的后端 API。我正在使用 Symfony HTTP 缓存来加速我的一些繁重的响应。
我处于测试阶段,所以我的后端 API 添加了
Access-Control-Allow-Headers:"*" 回复所有回复。
但是,缓存的响应存在问题。在它们的标头中,Access-Control-Allow-Headers:"*" 被Access-Control-Allow-Headers:"example.com" 覆盖,其中example.com 是在缓存之前请求资源的客户端地址。
所以,如果我在地址 www.example.com 而不是地址 example.com 上打开我的前端应用程序,我会在萤火虫中看到以下错误
XMLHttpRequest cannot load https://backend.com/tests/all.
The 'Access-Control-Allow-Origin' header has a value 'http://example.com'
that is not equal to the supplied origin.
Origin 'http://www.example.com' is therefore not allowed access.
我正在使用 NelmioCorsBundle,它将 CORS 标头支持添加到我的 Symfony3 应用程序。
【问题讨论】:
标签: angularjs symfony caching cors nelmiocorsbundle