CORSを設定しよう
php artisan config:publish cors
php artisan config:clear
すべてのリクエストに設定するには、config/cors.php
を変更してね
config/cors.php
// 変更前
'paths' => ['api/*', 'sanctum/csrf-cookie'],
// 変更後
'paths' => ['*', 'sanctum/csrf-cookie'],
エラー内容
Access to fetch at 'https://example.jp' from origin 'https://example.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.