Skip to content

Commit ff3b432

Browse files
committed
feat: add custom domain pattern configuration for CORS and update origin retrieval
1 parent fd1e995 commit ff3b432

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

config/blog-api.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@
55
/* Set route prefix for the blog API */
66
'route_prefix' => env('BLOG_API_ROUTE_PREFIX', 'api'),
77
],
8+
9+
'cors_custom_domain_pattern' => env('CORS_CUSTOM_DOMAIN_PATTERN', '/^$/'),
810
];

src/Http/Middlewares/CorsMiddleware.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,10 @@ private function getAllowedOrigins(): array
7676
{
7777
$baseOrigins = [
7878
// Environment-specific URLs from .env
79-
env('BLOG_FE_URL'),
80-
env('BLOG_ADMIN_URL'),
81-
env('BLOG_API_URL'),
82-
env('APP_URL'),
79+
config('blog-core.fe_url'),
80+
config('blog-core.admin_url'),
81+
config('blog-core.api_url'),
82+
config('app.url'),
8383

8484
// Development origins
8585
'http://localhost',
@@ -139,7 +139,7 @@ private function getAllowedPatterns(): array
139139
*/
140140
private function getCustomDomainPattern(): string
141141
{
142-
$customDomain = env('CORS_CUSTOM_DOMAIN_PATTERN');
142+
$customDomain = config('blog-api.cors_custom_domain_pattern');
143143
return $customDomain ?: '/^$/'; // Empty pattern if not set
144144
}
145145

0 commit comments

Comments
 (0)