I have a Symfony2 application which I am trying to set up using the Nelmio CORS bundle. I am running this on an apache server (BitNami mampstack).
No matter what I do, I keep getting this error logged to my browser's console:
XMLHttpRequest cannot load http://localhost:8000/avrequests. Response to preflight request doesn't pass access control check: The 'Access-Control-Allow-Origin' header contains the invalid value 'null'. Origin 'http://localhost:8080' is therefore not allowed access.
Sure enough my response headers read like this:
Access-Control-Allow-Origin:null
Cache-Control:no-cache
Connection:close
Content-Type:text/html; charset=UTF-8
Date:Sun, 29 Nov 2015 05:14:13 GMT
Host:localhost:8000
X-Debug-Token:3f40a5
X-Debug-Token-Link:/_profiler/3f40a5
X-Powered-By:PHP/5.5.27
This is the Nelmio configuration in my config.yml file (it's basically default values):
nelmio_cors:
defaults:
allow_credentials: false
allow_origin: []
allow_headers: []
allow_methods: []
expose_headers: []
max_age: 0
hosts: []
origin_regex: false
paths:
'^/':
allow_origin: ['*']
allow_headers: ['origin', 'content-type']
allow_methods: ['POST', 'PUT', 'GET', 'DELETE','OPTIONS']
max_age: 3600
I have tried everything from adding this line into the httpd.conf file....
Header set Access-Control-Allow-Origin "*"
...to creating an .htaccess file. The bundle is properly included in my AppKernel.php file within Symfony. Nothing works; I cannot get anything to properly set the Access-Control-Allow-Origin header.