nextjs rewrite
Answered
Blanc de Hotot posted this in #help-forum
Blanc de HototOP
Hope everyone is doing well
I have a problem related to nextjs proxy and also related to nodejs.
When user send req to /api using
I will leave this message in here in case someone had this problem before. Thank you
I have a problem related to nextjs proxy and also related to nodejs.
When user send req to /api using
frontend domain it must redirect him to backend domain and this working well but only in developement mode once i do npm run build, it gives me multiple errors saying can't fetch which basically mean that redirection logic doesn't work on production modemodule.exports = {
async rewrites() {
return [
{
source: "/api/:path*",
destination: "https://backend.vercel.app/:path*", // Proxy to Backend
},
];
},
}I will leave this message in here in case someone had this problem before. Thank you
Answered by Blanc de Hotot
exactly as a solution i had to handle production rewrite in vercel file
vercel.json2 Replies
it’s not redirect 307 but rewrite, reverse proxy.
Blanc de HototOP
exactly as a solution i had to handle production rewrite in vercel file
vercel.jsonAnswer