Fix nginx: route GET /login to frontend, POST /login to backend
The previous regex routed all methods for /login to the backend. A browser navigating to /login sends GET, which returned 405 because the backend only has POST /login. Now GET goes to the React SPA. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -23,18 +23,38 @@ http {
|
|||||||
server {
|
server {
|
||||||
listen 80;
|
listen 80;
|
||||||
|
|
||||||
# API, HLS-Streams, Auth
|
# API + HLS + ping: immer Backend
|
||||||
location ~ ^/(api|hls|login|logout|ping)(/.*)?$ {
|
location ~ ^/(api|hls|ping)(/.*)?$ {
|
||||||
proxy_pass http://backend;
|
proxy_pass http://backend;
|
||||||
proxy_set_header Host $host;
|
proxy_set_header Host $host;
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
proxy_read_timeout 300s;
|
proxy_read_timeout 300s;
|
||||||
# HLS streaming: disable buffering
|
|
||||||
proxy_buffering off;
|
proxy_buffering off;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Cover images / static media served by backend
|
# POST /login → Backend (ABS-API), GET /login → Frontend (React SPA)
|
||||||
|
location = /login {
|
||||||
|
if ($request_method = POST) {
|
||||||
|
proxy_pass http://backend;
|
||||||
|
}
|
||||||
|
proxy_pass http://frontend;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_read_timeout 300s;
|
||||||
|
}
|
||||||
|
|
||||||
|
# POST /logout → Backend
|
||||||
|
location = /logout {
|
||||||
|
if ($request_method = POST) {
|
||||||
|
proxy_pass http://backend;
|
||||||
|
}
|
||||||
|
proxy_pass http://frontend;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Cover images
|
||||||
location /covers/ {
|
location /covers/ {
|
||||||
proxy_pass http://backend;
|
proxy_pass http://backend;
|
||||||
proxy_set_header Host $host;
|
proxy_set_header Host $host;
|
||||||
@@ -42,7 +62,7 @@ http {
|
|||||||
add_header Cache-Control "public";
|
add_header Cache-Control "public";
|
||||||
}
|
}
|
||||||
|
|
||||||
# Frontend (React SPA)
|
# Frontend (React SPA) — alle anderen Routen
|
||||||
location / {
|
location / {
|
||||||
proxy_pass http://frontend;
|
proxy_pass http://frontend;
|
||||||
proxy_set_header Host $host;
|
proxy_set_header Host $host;
|
||||||
|
|||||||
Reference in New Issue
Block a user