|
@@ -1,54 +1,11 @@
|
|
|
<?php
|
|
|
-
|
|
|
return [
|
|
|
- // 指定哪些路由需要 CORS
|
|
|
- 'paths' => [
|
|
|
- '*', // 所有路由
|
|
|
- 'api/*', // API 路由
|
|
|
- 'sanctum/csrf-cookie', // Sanctum 认证
|
|
|
- 'login', // 登录路由
|
|
|
- 'register', // 注册路由
|
|
|
- ],
|
|
|
-
|
|
|
- // 允许的请求方法
|
|
|
- 'allowed_methods' => ['*', 'GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'],
|
|
|
-
|
|
|
- // 允许的来源域名
|
|
|
- 'allowed_origins' => [
|
|
|
- '*',
|
|
|
- 'http://127.0.0.1',
|
|
|
- 'http://localhost',
|
|
|
- env('APP_ENV') === 'local'
|
|
|
- ? ['http://localhost:3000', 'http://localhost:8080', 'http://127.0.0.1:8000', '*']
|
|
|
- : [env('FRONTEND_URL'), '*'],
|
|
|
- ],
|
|
|
-
|
|
|
- // 允许的域名模式(支持通配符)
|
|
|
- 'allowed_origins_patterns' => [
|
|
|
- // 'https://*.your-domain.com',
|
|
|
- ],
|
|
|
-
|
|
|
- // 允许的请求头
|
|
|
- 'allowed_headers' => [
|
|
|
- '*',
|
|
|
- 'Accept',
|
|
|
- 'Authorization',
|
|
|
- 'Content-Type',
|
|
|
- 'X-Requested-With',
|
|
|
- 'X-CSRF-TOKEN',
|
|
|
- 'X-Custom-Header',
|
|
|
- env('APP_ENV') === 'local' ? 'X-Debug-Token' : null,
|
|
|
- ],
|
|
|
-
|
|
|
- // 暴露给客户端的响应头
|
|
|
- 'exposed_headers' => [
|
|
|
- '*',
|
|
|
- 'X-Custom-Response-Header',
|
|
|
- ],
|
|
|
-
|
|
|
- // 预检请求缓存时间(秒)
|
|
|
- 'max_age' => 86400,
|
|
|
-
|
|
|
- // 是否允许携带认证信息(cookies等)
|
|
|
- 'supports_credentials' => env('CORS_SUPPORTS_CREDENTIALS', true),
|
|
|
+ 'paths' => ['api/*'],
|
|
|
+ 'allowed_methods' => ['*'],
|
|
|
+ 'allowed_origins' => ['*'],
|
|
|
+ 'allowed_origins_patterns' => [],
|
|
|
+ 'allowed_headers' => ['*'],
|
|
|
+ 'exposed_headers' => [],
|
|
|
+ 'max_age' => 0,
|
|
|
+ 'supports_credentials' => true,
|
|
|
];
|