From 14c41e1a545f82d42a5ae4904215ef2ba2299ed5 Mon Sep 17 00:00:00 2001 From: Malin Date: Tue, 21 Apr 2026 09:32:49 +0200 Subject: [PATCH] fix: use exact location match for /api to prevent 301 on POST location /api/ caused nginx to 301-redirect POST /api -> /api/ Browsers follow 301 with GET, breaking JSON-RPC. Exact match location = /api proxies directly without redirect. Co-Authored-By: Claude Sonnet 4.6 --- nginx.conf | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/nginx.conf b/nginx.conf index 1a46009..2d8f296 100644 --- a/nginx.conf +++ b/nginx.conf @@ -9,11 +9,14 @@ server { } # Proxy API calls to the backend service - location /api/ { + # Exact match on /api — avoids the 301 redirect nginx emits for + # location /api/ when the client posts to bare /api (POST→GET on 301) + location = /api { proxy_pass http://backend:5000/; 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_set_header X-Forwarded-Proto $scheme; } # Rewrite /{lang}/result/{id} to /{lang}/result/id/index.html