#How can I connect the Laravel 11 API to Angular 18?
15 messages ยท Page 1 of 1 (latest)
You need to configure CORS in laravel, so it allows requests from your Angular application (This is not related to Angular, but to how browsers handle cross origin requests). See https://laravel.com/docs/11.x/routing#cors
Have you tried?
php artisan config:publish cors
And then in config/cors.php add http://localhost:4200 in allowed_origins?
just enable CORS on config using * or white list url
this is my CORS file
try this
'paths' => ['api/*', 'sanctum/csrf-cookie'],
'allowed_methods' => ['*'],
'allowed_origins' => ['*'],
'allowed_origins_patterns' => [],
'allowed_headers' => ['*'],
'exposed_headers' => [],
'max_age' => 0,
'supports_credentials' => false,
];
this is what the errors says
did u try my code?
I did
this is my app.php in bootstrap file do you think theres something wrong here?
or change this 'paths' => ['foodly-api/api/*', 'sanctum/csrf-cookie'],
looks like the problem is solved ๐
the error is still there ๐ฆ