且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Apache/Laravel 403 Forbidden-不允许头

更新时间:2023-02-24 08:40:16

很好,我找到了解决方案.我禁用了laravel-cors,并通过此配置在public/.htaccess中启用了跨域.

Great, I found a solution. I disabled laravel-cors and I enabled the cross-domain in public/.htaccess with this piece of configuration.

# with AJAX withCredentials=false (cookies NOT sent)
Header always set Access-Control-Allow-Origin "*"                   
Header always set Access-Control-Allow-Methods "POST, GET, PUT, OPTIONS, PATCH, DELETE" 
Header always set Access-Control-Allow-Headers "X-Accept-Charset,X-Accept,Content-Type"
RewriteEngine On                  
RewriteCond %{REQUEST_METHOD} OPTIONS 
RewriteRule ^(.*)$ $1 [R=200,L,E=HTTP_ORIGIN:%{HTTP:ORIGIN}]]

# with AJAX withCredentials=true (cookies sent, SSL allowed...)
SetEnvIfNoCase ORIGIN (.*) ORIGIN=$1
Header always set Access-Control-Allow-Methods "POST, GET, PUT, OPTIONS, PATCH, DELETE" 
Header always set Access-Control-Allow-Origin "%{ORIGIN}e"
Header always set Access-Control-Allow-Credentials "true"
Header always set Access-Control-Allow-Headers "X-Accept-Charset,X-Accept,Content-Type"
RewriteEngine On
RewriteCond %{REQUEST_METHOD} OPTIONS
RewriteRule ^(.*)$ $1 [R=200,L,E=HTTP_ORIGIN:%{HTTP:ORIGIN}]

现在一切正常!希望这会在将来对遇到相同问题的人有所帮助.

Everything work well now ! Hope this will help somebody with the same issue in the future.