Snippi
A super awesome snippet tool.
- 1.
<VirtualHost *:80> # Or whatever VHost you're using
- 2.
# Your other rules
- 3.
RewriteEngine on
- 4.
RewriteCond %{REQUEST_METHOD} OPTIONS
- 5.
RewriteRule ^(.*)$ "index.html" [R=200,E=API:1,PT]
- 6.
# This rewrite rule forces any OPTIONS request to return as a valid response.
- 7.
# It sets the API environment variable for use below.
- 8.
#
- 9.
# You can try to put a placeholder file here for the response (index.html)
- 10.
# Otherwise it'll look like an error page, but it'll return with a 200 response code.
- 11.
# Since this is intended to pass along the headers below and likely wont be visible,
- 12.
# it doesn't really matter what the response content is.
- 13.
- 14.
<IfModule mod_headers.c>
- 15.
SetEnvIf Accept application/json API
- 16.
Header always set Access-Control-Allow-Origin "*" env=API
- 17.
Header always set Access-Control-Allow-Methods "POST, GET, OPTIONS, DELETE, PUT" env=API
- 18.
Header always set Access-Control-Allow-Headers "Access-Control-Allow-Headers, Origin, Accept, X-Requested-With, Content-Type, Access-Control-Request-Method, Access-Control-Request-Headers, Authorization" env=API
- 19.
</IfModule>
- 20.
</VirtualHost>