Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

rajeshupadhayaya's avatar

CORS issue in production server

Hi, I have created laravel API and configured CORS and it works fine in development server. But when i deployed that application in shared hosting. It starts giving CORS issue.

After some testing and debugging I found that OPTION request in my production server doesn't returns with CORS header but in development server it does.

Did any face similar issue? or know how to fix that?

0 likes
5 replies
bugsysha's avatar

Have you configured everything on production? What have you configured?

rajeshupadhayaya's avatar

It's a share hosting server, so i followed the step require to host website. I already have experience in deploying laravel site in share hosting server and had done it plenty of time in past with no issues. But this is the first time for Laravel API.

So my laravel is using fruitcake/CORS middleware to deal with CORS which works perfectly in local server spin up with artisan command.

But when i deploy it to Apache server, my angular application gives CORS issue. I have verified OPTIONS request with postman for both local and Apache(Prod) server and they both returned with same header and it works locally but not with apache server.

I have tried by adding headers using .htaccess but no progress so far.

rajeshupadhayaya's avatar

Issue resolved. I had to delete below code from .htaccess.

`

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_URI} (.+)/$

RewriteRule ^ %1 [L,R=301]

`

Please or to participate in this conversation.