• 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>
<VirtualHost *:80> # Or whatever VHost you're using # Your other rules RewriteEngine on RewriteCond %{REQUEST_METHOD} OPTIONS RewriteRule ^(.*)$ "index.html" [R=200,E=API:1,PT] # This rewrite rule forces any OPTIONS request to return as a valid response. # It sets the API environment variable for use below. # # You can try to put a placeholder file here for the response (index.html) # Otherwise it'll look like an error page, but it'll return with a 200 response code. # Since this is intended to pass along the headers below and likely wont be visible, # it doesn't really matter what the response content is. <IfModule mod_headers.c> SetEnvIf Accept application/json API Header always set Access-Control-Allow-Origin "*" env=API Header always set Access-Control-Allow-Methods "POST, GET, OPTIONS, DELETE, PUT" env=API 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 </IfModule> </VirtualHost>

Copy Code to Clipboard Raw

Sign-in or Create a Free Account.

Snippi uses Twitter or Facebook to register and create accounts. Registration will enable you to keep track of your snippets. We never spam your timeline or wall. Ever.

Sign-in with Facebook Sign-in with Twitter