drupal-with-nginx
drupal-with-nginx copied to clipboard
CORS
I faced with problem where using subdomain and can not execute requests between subdomains. This problem related with CORS. Need to add header: "Access-Control-Allow-Origin", "Access-Control-Allow-Methods", "Access-Control-Allow-Headers" to allow browser execute requests.
I use angularjs as frontend and drupal as backend. Thanks.
Well It's quite easy. What Just add the headers in a file, call it CORS basic and include it. For example:
## Basic CORS support.
add_header Access-Control-Allow-Origin '$http_origin' always;
add_header Access-Control-Allow-Credentials true always;
add_header Access-Control-Allow-Headers 'Origin, X-Requested-With, Content-Type, Accept, Authorization';
add_header Access-Control-Expose-Headers 'Authorization';
It depends on which headers and methods you want to allow. The above was used for an app where a JWT was being used. Therefore the Authorization
header.
I will add a config file for this soon. Thanks for opening this issue. Now we live in a APi + frontend world indeed.
include it where?