handling CORS preflight request in Apache

前端 未结 3 1194
走了就别回头了
走了就别回头了 2021-01-02 19:29

I have a AngularJS app deployed using Yeoman. Cakephp RESTful backend.

The Angular app sends in OPTIONS preflight requests, which the backend responds with forbidden

3条回答
  •  醉话见心
    2021-01-02 20:16

    I had the same question and the answer given does not solve the problem.

    By looking around more I found you could do this using the rewrite, e.g:

    RewriteEngine On                  
    RewriteCond %{REQUEST_METHOD} OPTIONS 
    RewriteRule ^(.*)$ $1 [R=200,L]    
    

    (make sure you enable the rewrite mod)

    Then you should use, the "always set" to set the headers, e.g:

    Header always set Access-Control-Allow-Origin "*"                   
    Header always set Access-Control-Allow-Methods "POST, GET, OPTIONS"
    

    Explanations here: https://serverfault.com/questions/231766/returning-200-ok-in-apache-on-http-options-requests

提交回复
热议问题