mirror of
https://github.com/khoaliber/LetterFeed.git
synced 2026-03-02 13:18:27 +00:00
19 lines
519 B
TypeScript
19 lines
519 B
TypeScript
import { NextRequest, NextResponse } from 'next/server';
|
|
|
|
export function middleware(request: NextRequest) {
|
|
const backendUrl = process.env.LETTERFEED_BACKEND_URL || 'http://backend:8000';
|
|
|
|
if (request.nextUrl.pathname.startsWith('/api/')) {
|
|
const url = request.nextUrl.clone();
|
|
const path = url.pathname.replace('/api', '');
|
|
url.href = `${backendUrl}${path}${url.search}`;
|
|
return NextResponse.rewrite(url);
|
|
}
|
|
|
|
return NextResponse.next();
|
|
}
|
|
|
|
export const config = {
|
|
matcher: '/api/:path*',
|
|
};
|