Next.js Discord

Discord Forum

How to make an API route dynamic?

Answered
Chartreux posted this in #help-forum
Open in Discord
ChartreuxOP
I couldn't help but notice my API route in NextJS 14 is static instead of dynamic. How do you work around this?
https://olliedean.co.uk/api/nowplaying
As you can see, to test this I make a field in my response that just pulls the current time, but it is stuck on the time of build.
Answered by Chartreux
Nevermind I found a fix 😂 For anyone having this issue, add this to your API route:
export const dynamic = "force-dynamic";
View full answer

1 Reply

ChartreuxOP
Nevermind I found a fix 😂 For anyone having this issue, add this to your API route:
export const dynamic = "force-dynamic";
Answer