fix(middleware): fetch redirects via 127.0.0.1 — localhost resolves to ::1 in Docker
Some checks are pending
CI / Type Check (push) Waiting to run
CI / Lint (push) Waiting to run
CI / Unit Tests (push) Waiting to run
Deploy / Build & Push Image (push) Waiting to run
Deploy / Deploy to VPS (push) Blocked by required conditions

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Vadym Samoilenko 2026-06-12 11:04:23 +01:00
parent 109b3d058e
commit 03cd2e39ab

View file

@ -28,7 +28,9 @@ async function getRedirects(siteURL: string) {
}
export async function middleware(request: NextRequest) {
const siteURL = process.env['NEXT_PUBLIC_SITE_URL'] ?? 'http://localhost:3000'
// Internal self-fetch: must be 127.0.0.1, not localhost — in Docker localhost
// resolves to ::1 while Next listens on IPv4 only, so the fetch fails silently.
const siteURL = process.env['INTERNAL_API_URL'] ?? 'http://127.0.0.1:3000'
const pathname = request.nextUrl.pathname
const redirects = await getRedirects(siteURL)