diff --git a/config/cors.php b/config/cors.php index a3b4e8d..a703866 100755 --- a/config/cors.php +++ b/config/cors.php @@ -21,16 +21,20 @@ return [ 'allowed_origins' => array_filter(array_map('trim', explode(',', env( 'CORS_ALLOWED_ORIGINS', - 'https://yxbd-fangke.ali251.langye.net,http://localhost:8020,http://127.0.0.1:8020' + 'https://yxbd-fangke.ali251.langye.net,http://localhost:8020,http://127.0.0.1:8020,http://localhost:8021,http://127.0.0.1:8021' )))), - 'allowed_origins_patterns' => [], + // 允许本地开发端口灵活变更(如 8020/8021/8080 等) + 'allowed_origins_patterns' => [ + '/^http:\/\/localhost(?::\d+)?$/', + '/^http:\/\/127\.0\.0\.1(?::\d+)?$/', + ], 'allowed_headers' => ['*'], 'exposed_headers' => [], - 'max_age' => 0, + 'max_age' => 86400, 'supports_credentials' => true,