abu abu
abu abu

Reputation: 7022

Response to CORS preflight OPTIONS request is 500 Internal Server Error in Laravel API

I am working on a Laravel and Angular project. Project is running well in another Computer but I am getting below error in my Laptop.

I used this package. I tried several ways but could not find any solution.

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource

enter image description here

enter image description here

My .htaccess file is like below

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews -Indexes
    </IfModule>

    RewriteEngine On

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

Could anyone help me in this regard ?

Upvotes: 5

Views: 13983

Answers (1)

piscator
piscator

Reputation: 8709

You are only allowed to set the Access-Control-Allow-Origin header once.

It seems this header is also set somewhere else than in the laravel-cors package configuration. For example in your .htaccess file, in your server configuration or (less likely since you get the exception only in one environment) in some other middleware you have created manually.

Upvotes: 2

Related Questions