I’ve configured my laravel 11 application to handle cors using the following cors.php file in the config dir
<?php
return [
'paths' => ['*'],
'allowed_methods' => ['GET, POST, PUT, OPTIONS'],
'allowed_origins' => ['http://localhost:8082'],
'allowed_origins_patterns' => [],
'allowed_headers' => ['Origin, Content-Type, X-Auth-Token , Cookie'],
'exposed_headers' => [],
'max_age' => 0,
'supports_credentials' => true,
];
my local server at 8082 is trying to access the laravel server at 8000 but im getting cors issue from the browser
index.html:1 Access to XMLHttpRequest at 'http://localhost:8000/game/server?sessionId=475826' from origin 'http://localhost:8082' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
what i dont understand is that it seems to be working, the OPTIONS request is getting 204 response and i can see the headers on the dev tools
the actual POST request is missing these headers
and i can actually debug the response method – meaning that the request is indeed getting to the server.
on postman i get a normal response