Refactor code structure for improved readability and maintainability
This commit is contained in:
@@ -13,6 +13,29 @@ location /lms-api/ {
|
||||
}
|
||||
|
||||
location /cms-api/ {
|
||||
# CORS safety net at proxy level for CMS API.
|
||||
set $cors_origin "";
|
||||
if ($http_origin ~* "^https?://([a-z0-9-]+\\.)?norteamericano\\.(com|cl)$") {
|
||||
set $cors_origin $http_origin;
|
||||
}
|
||||
if ($http_origin ~* "^http://localhost(:[0-9]+)?$") {
|
||||
set $cors_origin $http_origin;
|
||||
}
|
||||
|
||||
if ($request_method = OPTIONS) {
|
||||
add_header Access-Control-Allow-Origin $cors_origin always;
|
||||
add_header Vary "Origin, Access-Control-Request-Method, Access-Control-Request-Headers" always;
|
||||
add_header Access-Control-Allow-Methods "GET,POST,PUT,DELETE,OPTIONS,PATCH,HEAD" always;
|
||||
add_header Access-Control-Allow-Headers "content-type,authorization,x-requested-with,x-organization-id,range" always;
|
||||
add_header Access-Control-Max-Age 86400 always;
|
||||
add_header Content-Length 0 always;
|
||||
add_header Content-Type "text/plain; charset=utf-8" always;
|
||||
return 204;
|
||||
}
|
||||
|
||||
add_header Access-Control-Allow-Origin $cors_origin always;
|
||||
add_header Vary "Origin" always;
|
||||
|
||||
rewrite ^/cms-api/(.*)$ /$1 break;
|
||||
proxy_pass http://openccb-studio:3001;
|
||||
proxy_set_header Host $host;
|
||||
|
||||
@@ -9,6 +9,29 @@ client_body_timeout 1800s;
|
||||
# Prefer the explicit `/cms-api/*` prefix for frontend fetches. This avoids collisions
|
||||
# with Next.js pages like `/courses` and `/admin` that share the same host.
|
||||
location /cms-api/ {
|
||||
# CORS safety net at proxy level for CMS API.
|
||||
set $cors_origin "";
|
||||
if ($http_origin ~* "^https?://([a-z0-9-]+\\.)?norteamericano\\.(com|cl)$") {
|
||||
set $cors_origin $http_origin;
|
||||
}
|
||||
if ($http_origin ~* "^http://localhost(:[0-9]+)?$") {
|
||||
set $cors_origin $http_origin;
|
||||
}
|
||||
|
||||
if ($request_method = OPTIONS) {
|
||||
add_header Access-Control-Allow-Origin $cors_origin always;
|
||||
add_header Vary "Origin, Access-Control-Request-Method, Access-Control-Request-Headers" always;
|
||||
add_header Access-Control-Allow-Methods "GET,POST,PUT,DELETE,OPTIONS,PATCH,HEAD" always;
|
||||
add_header Access-Control-Allow-Headers "content-type,authorization,x-requested-with,x-organization-id,range" always;
|
||||
add_header Access-Control-Max-Age 86400 always;
|
||||
add_header Content-Length 0 always;
|
||||
add_header Content-Type "text/plain; charset=utf-8" always;
|
||||
return 204;
|
||||
}
|
||||
|
||||
add_header Access-Control-Allow-Origin $cors_origin always;
|
||||
add_header Vary "Origin" always;
|
||||
|
||||
rewrite ^/cms-api/(.*)$ /$1 break;
|
||||
proxy_pass http://openccb-studio:3001;
|
||||
proxy_request_buffering off;
|
||||
|
||||
Reference in New Issue
Block a user