我在同一個Ubuntu Apache服務器上有兩個laravel項目。Laravel Apache Project中請求的資源上沒有'Access-Control-Allow-Origin'標頭
項目A可在www.EXAMPLE.com的test.EXAMPLE.com和「項目B」中找到。 「項目A」有一個網站,我向項目B發出了AJAX請求。在每個項目中,我都有一個GoDaddy SSL證書(一個用於test.EXAMPLE.com,另一個用於www.EXAMPLE.com)。
我得到的錯誤是:
XMLHttpRequest cannot load https://www.EXAMPLE.com/api_url. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://test.EXAMPLE.com' is therefore not allowed access.
我該如何解決這個問題?我嘗試添加 「項目B」 裏面一個.htaccess與
Header set Access-Control-Allow-Origin "*"
,並且還加入在 「Project A」 AJAX頭,這
'Access-Control-Allow-Origin' : '*',
'Access-Control-Allow-Methods' : 'GET, POST, PUT, DELETE, OPTIONS'
誰可以幫我,謝謝。
就我而言,這並沒有改變任何東西。我將這個中間件添加到我所調用的路由中,問題仍然存在。 –
關於什麼?實際的電話或預檢請求? – Robert