Skip to content

Instantly share code, notes, and snippets.

@Rinlama
Created May 15, 2019 04:20
Show Gist options
  • Select an option

  • Save Rinlama/822cacd286632e2aca1204e82b366b34 to your computer and use it in GitHub Desktop.

Select an option

Save Rinlama/822cacd286632e2aca1204e82b366b34 to your computer and use it in GitHub Desktop.
Laravel Access-Control-Allow-Origin
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Methods "POST, GET, OPTIONS, DELETE, PUT"
Header set Access-Control-Max-Age "1000"
Header set Access-Control-Allow-Headers "Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With"
</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment