Proper 3rd party APIs config in Next.js

Hey everyone, I tried to move a set of serverless functions to a standalone Fastify server for some reasons which are not relevant to this question. I faced an issue with request headers when I tried sending requests using fetch to my Fastify server. The headers coming from Next.js were totally different from the headers I'd expected. I tried comparing headers from my Next.js API route and from Fastify, and they were missing some fields like the Clerk auth token. I edited the next.config.js like so to solve this issue
async rewrites() {
return [
{
source: "/fastify/api/db/preview",
destination: "http://localhost:8000/api/db/preview",
},
];
},
async rewrites() {
return [
{
source: "/fastify/api/db/preview",
destination: "http://localhost:8000/api/db/preview",
},
];
},
And now I have access to all headers coming from Next.js. My question again guys is, do you think this is good practice? And how could I make it scale if I have a large set of Fastify API endpoints? Thank you.
0 Replies
No replies yetBe the first to reply to this messageJoin