fruitcake / laravel-cors

Adds CORS (Cross-Origin Resource Sharing) headers support in your Laravel application
MIT License
6.27k stars 613 forks source link

bug: Fix "has been blocked by CORS policy" #475

Closed taha-moghaddam closed 3 years ago

taha-moghaddam commented 4 years ago

My code is dirty and will not work because it needs to change $this->options variable to public on CorsService and this is on another github projects(asm89/stack-cors) but I can describe to know the result of my debugging and why do this. Some requests get "has been blocked by CORS policy" error on line 59 when the $next has not respond the $response variable yet. So I consider to add Access-Control-Allow-Origin header before handling $next and problem fixed. But now we have new problem which is multiple Access-Control-Allow-Origin values, So I added line 78 which will remove duplicate Access-Control-Allow-Origin headers. Now all thing work correctly on my server but the problem with the code above as I said is $this->cors->options is private.

barryvdh commented 4 years ago

Are you exiting/dd'ing? Or why wouldn't $next be called? Using the php header functions is not an option though.