use middleware for runtime backend proxy

This commit is contained in:
2026-04-14 22:48:00 -06:00
parent 2a2c9ac707
commit a241024ced
2 changed files with 11 additions and 8 deletions

11
web/middleware.js Normal file
View File

@@ -0,0 +1,11 @@
import { NextResponse } from 'next/server'
export function middleware(request) {
const backendUrl = process.env.BACKEND_URL || 'http://localhost:8080'
const { pathname, search } = request.nextUrl
return NextResponse.rewrite(new URL(pathname + search, backendUrl))
}
export const config = {
matcher: '/api/:path*',
}