Apache webserver
Create a .htaccess
file in the {your_website_root}/.well-known/
directory.
Header set Access-Control-Allow-Origin "*"
And reload Apache server with apachectl -k graceful
command.
Nginx
Open your config file (usually /etc/nginx/conf.d/{your_domain}.conf
), add the following lines into the server
directive:
location /.well-known {
allow all;
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS';
add_header 'Content-Type' 'text/plain; charset=utf-8';
add_header 'Content-Length' 0;
return 204;
}
if ($request_method = 'GET') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS';
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
}
}
Reload Nginx configuration: nginx -s reload
.
IIS 7
Create a web.config
file in the {your_website_root}/.well-known/
directory with the following content:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
</customHeaders>
</httpProtocol>
</system.webServer>
</configuration>
There is no need to restart a web-server, all changes in web.config
automatically reload corresponding application domain
.
Using different web-server?
Visit enable-cors.org, locate your web-server in the list and configure it accordingly to the above recommendations.