Fix Caddy routing: split API paths to backend, avoid /auth/login route collision
POST /auth/login was returning 405 because Next.js's filesystem page route at /auth/login (the login UI) shadows the afterFiles rewrite to the backend for every method, including POST. Route API paths (and non-GET/HEAD /auth/* requests) directly to the backend container at the Caddy layer instead, leaving GET/HEAD /auth/login to render the frontend login page.
This commit is contained in:
@@ -1,3 +1,19 @@
|
|||||||
{$DOMAIN} {
|
{$DOMAIN} {
|
||||||
|
# Backend API paths with no corresponding frontend pages.
|
||||||
|
@api {
|
||||||
|
path /households /households/* /poi /poi/* /land /land/* /gas-station /gas-station/* /health
|
||||||
|
}
|
||||||
|
reverse_proxy @api backend:4000
|
||||||
|
|
||||||
|
# /auth/* -> backend, except GET/HEAD /auth/login which is the frontend login page.
|
||||||
|
@authBackend {
|
||||||
|
path /auth/*
|
||||||
|
not {
|
||||||
|
path /auth/login
|
||||||
|
method GET HEAD
|
||||||
|
}
|
||||||
|
}
|
||||||
|
reverse_proxy @authBackend backend:4000
|
||||||
|
|
||||||
reverse_proxy frontend:3000
|
reverse_proxy frontend:3000
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user