Last active
May 25, 2019 05:45
-
-
Save ericcgu/6de73b6f4014df04e28762d6d896f061 to your computer and use it in GitHub Desktop.
Apache 2.4 CORS httpd.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. Load Modules | |
``` | |
LoadModule headers_module modules/mod_headers.so | |
LoadModule rewrite_module modules/mod_rewrite.so | |
``` | |
2. Change Folder in Bold to your target directory serving the endpoint: | |
``` | |
<Directory "**/usr/local/apache2**"> | |
AllowOverride None | |
Require all granted | |
Header always set Access-Control-Allow-Origin "*" | |
Header always set Access-Control-Allow-Methods "POST, GET, OPTIONS, DELETE, PUT" | |
Header always set Access-Control-Allow-Headers "x-requested-with, Content-Type, origin, authorization, accept, client-security-token" | |
Header always set Access-Control-Expose-Headers "Content-Security-Policy, Location" | |
Header always set Access-Control-Max-Age "600" | |
RewriteEngine On | |
RewriteCond %{REQUEST_METHOD} OPTIONS | |
RewriteRule ^(.*)$ $1 [R=200,L] | |
</Directory> | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment