-
SummaryHey guys, App deployed to self-hosted windows server I have an application deployed to server using 'standalone' output. Application has like 4 pages, mostly done on client-side. I also have some Route Handlers/Api Routes which points our .NET api (so external api). Locally Next.js works very slow but after deployment I see that it works pretty good but! When I open page I have some requests done of course via SWR. 3 dictionaries (extra small) and one for search grid which is actually with pagination so also pretty small. Rest are regarding prefetching pages propably + current page (_rsc=xxx) But when I start refreshing it starts working fine BUT only for like 5 seconds. After 5-10 seconds idle I'm getting again 1-2 seconds. Problem is not with external api - when I try to use it for these endpoints, it's always between 50-250ms. I also tried running for example one of the dictionaries without UI so just /api/,,, endpoint and still the same. ON PROD. Question is what can be wrong? I search for like two days, reddit, discord channel and nothing. Additional informationNextJs 15.5.4 - App RouterExampleNo response |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 15 replies
-
|
Hi! This is a common issue with Next.js standalone mode. Here are a few things to check: Possible Causes
SolutionsTry adding these to your module.exports = {
experimental: {
optimizeCss: true,
optimizePackageImports: ['your-packages']
},
// Warm up the server
onDemandEntries: {
maxInactiveAge: 60 * 1000,
pagesBufferLength: 5,
}
}Also, you can implement a health check endpoint that keeps the server warm. Let me know if this helps! |
Beta Was this translation helpful? Give feedback.
-
|
And once you fall into the 1s range, it doesn't ever go back down? I think some data revalidation might be at play here... Btw, do you fetch from your own Next.js endpoints into your server components? THat's an extra HTTP round-trip that's bound to add latency. |
Beta Was this translation helpful? Give feedback.





Hey, just for descendants :) I resolved the issue with my teammates after days of research and trying different approaches. Final result - IIS URL Rewrite (proxy) on Windows Server. It seems like microsoft's module for proxy works in this way or nextjs cannot properly go through, hard to say. First I tried with setting keepAliveTimeout to some bigger value like 60_000. It started to work a little bit better but wasn't what I want. The solution was to change rewrite rules, not even the pattern but localhost - for example if you have localhost:3000 then it needs to be 127.0.0.1:3000 - seems like URL Rewrite module (proxy) has different steps when going through it till catch your Nextjs app …