-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Description
Astro Info
Astro v5.9.4
Node v22
System Linux (x64)
Package Manager npm
Output static
Adapter @astrojs/node
Integrations @astrojs/preact
If this issue only occurs in one browser, which browser is a problem?
Not browser specific.
Describe the Bug
I have an existing Astro site that has been in production, originally deployed as a static site served via Nginx inside a Docker container. This setup worked without issues, including proper rendering of the default 404 page when visiting unknown routes.
Recently, I needed to add a contact form, which required server-side processing. To support this, I switched the project to use the @astrojs/node adapter in standalone mode. Now, Astro is served via its built-in Node server, still running in Docker and behind nginxproxy/nginxproxy.
After this change:
- Home page and other valid routes load and work correctly
- astro dev and astro preview work locally with 404 behaving as expected.
- 404 page no longer renders in production when visiting non-existent routes. I don't get a response, the request is loading indefinitely.
In the docker container stdout logs I can see the following error at the moment when I try to access the page which is not present:
06:12:42 [@astrojs/node] Server listening on
local: http://localhost:4321
network: http://XXX:4321
06:13:01 [ERROR] [@astrojs/node] Unhandled rejection while rendering undefined
TypeError: fetch failed
at node:internal/deps/undici/undici:13510:13
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async #renderError (file:///app/server/chunks/_@astrojs-ssr-adapter_D6vczjnv.mjs:3374:29)
at async file:///app/server/chunks/_@astrojs-ssr-adapter_D6vczjnv.mjs:3693:24 {
[cause]: AggregateError [ECONNREFUSED]:
at internalConnectMultiple (node:net:1139:18)
at internalConnectMultiple (node:net:1215:5)
at afterConnectMultiple (node:net:1714:7) {
code: 'ECONNREFUSED',
[errors]: [ [Error], [Error] ]
}
}
06:13:01 [ERROR] [@astrojs/node] Unhandled rejection while rendering undefined
TypeError: fetch failed
at node:internal/deps/undici/undici:13510:13
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async #renderError (file:///app/server/chunks/_@astrojs-ssr-adapter_D6vczjnv.mjs:3374:29)
at async file:///app/server/chunks/_@astrojs-ssr-adapter_D6vczjnv.mjs:3693:24 {
[cause]: AggregateError [ECONNREFUSED]:
at internalConnectMultiple (node:net:1139:18)
at internalConnectMultiple (node:net:1215:5)
at afterConnectMultiple (node:net:1714:7) {
code: 'ECONNREFUSED',
[errors]: [ [Error], [Error] ]
}
}
My astro.config.mjs
export default defineConfig({
build: {
assets: "assets/generated",
},
vite: {
plugins: [tailwindcss()],
},
integrations: [preact()],
adapter: node({
mode: "standalone",
}),
});
Important: I am using on demand rendering as described in the docs. In other words, I don't have output: "server" specified in my astro config. Instead I append export const prerender = false; to my server side APIRoute.
I was not able to reproduce the issue on StackBlitz as it runs in dev mode, which works fine on my end as well. Will try and create a new repo with the reproducible code.
What's the expected result?
The Node standalone server should properly render the 404 page on invalid routes, just like it does in local development and in the previous static deployment setup.
Link to Minimal Reproducible Example
N/A
Participation
- I am willing to submit a pull request for this issue.