I have a frontend AngularJS app that consumes backend API written in Symfony 3. I am using Symfony HTTP Cache to speed up some of my heavy responses.
I am in the testing phase, so my backend API adds
Access-Control-Allow-Headers:"*" to all responses.
But, there is a problem with responses that are cached. In their header, Access-Control-Allow-Headers:"*" is overwritten with Access-Control-Allow-Headers:"example.com", where example.com is the client address that requested resource just before it was cached.
So, if I open my frontend app on the address www.example.com instead of address example.com I see following error in the firebug
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.
I am using NelmioCorsBundle that adds CORS headers support to my Symfony3 application.
Try setting
forced_allow_origin_value: *in your config:Per the configuration docs:
So to send
Access-Control-Allow-Origin: *, the exact value you want is literally*.