javascript - NextJS 13 ara katman yeniden yazması POST yönteminde düzgün çalışmıyor


Diğer dahili sunucuya isteği yeniden yazan NextJS ara yazılımını yazdım

import {NextRequest, NextResponse, URLPattern} from "next/server";
import {endpoint} from "@/utils";

export const config = {
    matcher: "/api/:path*"
}

const pattern = new URLPattern({pathname: "/api/:path*"})

export async function middleware(req: NextRequest) {

    const result = pattern.exec(req.url)

    console.log(result)
    if (result) {
        const path = result.pathname.groups.path

        return NextResponse.rewrite(`${endpoint}/${path}`)
    }
}

bu kod GET metodu için çalışıyor ama POST metodu için çalışmıyor (iç sunucu istek gövdesini almıyor)

next.config.js içinde rewrite yazdığımda işe yaradı

async rewrites() {
    return [
        {
            source: "/api/:path*",
            destination: `${process.env.API_ENDPOINT}/:path*`,
        },
    ]
},

NextJS ara katmanı kullanarak bunu nasıl çalıştırabilirim?

NextJS ara yazılımını kullanarak isteklere ek başlıklar eklemem gerekiyor ve bir ara yazılım fonksiyonu oluşturduğumda next.config.js yöntemi de işe yaramıyor (o fonksiyon hiçbir şey yapmasa bile)