Hi im using laravel as a backend and nextjs as a frontend im having trouble using the api and the cors ISSUES
here is my config/cors
'paths' => ['api/*', 'sanctum/csrf-cookie'],
'allowed_methods' => ['*'],
'allowed_origins' => [ '*',
'http://localhost:3000',
'https://ipims-git-master-gabriel-26s-projects.vercel.app'],
'allowed_origins_patterns' => [],
'allowed_headers' => ['*'],
'exposed_headers' => [],
'max_age' => 0,
'supports_credentials' => true,
ive also tried adding a customheaders middleware like this
class AddCustomHeaders
{
public function handle($request, Closure $next)
{
$response = $next($request);
$response->header('Access-Control-Allow-Origin', 'https://ipims-git-master-gabriel-26s-projects.vercel.app');
$response->header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
$response->header('Access-Control-Allow-Headers', 'Origin, Content-Type, X-Auth-Token, Authorization, Accept,charset,boundary,Content-Length');
$response->header('Access-Control-Allow-Credentials', 'true');
return $response;
}
}
but i still get errors
Access to XMLHttpRequest at 'https://hcvercel.vercel.app/api/api/chatGroupUsers' from origin 'https://ipims-git-master-gabriel-26s-projects.vercel.app' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
also im deploying both using 2 vercel deployments 1 for frontend and 1 for backend