我正在使用SLIM框架作爲後端和Angularjs作爲前端。正常的GET和POST API的工作正常。每當我在GET或POST方法中傳遞標頭時,它將引發404錯誤。我使用.htaccess文件的CORS。SLIM php Angularjs CORS
RewriteEngine On
# Some hosts may require you to use the `RewriteBase` directive.
# If you need to use the `RewriteBase` directive, it should be the
# absolute physical path to the directory that contains this htaccess file.
#
# RewriteBase/
Header add Access-Control-Allow-Origin: "*"
Header add Access-Control-Allow-Headers: "origin, x-requested-with, content-type, authorization"
Header add Access-Control-Allow-Methods: "PUT, GET, POST, DELETE, OPTIONS"
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
請幫我解決這個問題。
檢查您的服務器的錯誤日誌。哪些請求正在生成404響應? – Phil
機會是,您的服務器沒有正確響應飛行前的'OPTIONS'請求。讓我看看我能否找到一個全面解決方案 – Phil
好。我一直在嘗試這一個多星期。我無法得到它 – user3667960