Skip to content

/404 wont render when using expressjs with astro/node as middleware #14953

@bathtubfulloftoast

Description

@bathtubfulloftoast

Astro Info

Astro                    v5.16.4
Vite                     v6.4.1
Node                     v25.1.0
System                   Linux (x64)
Package Manager          pnpm
Output                   static
Adapter                  @astrojs/node (v9.5.1)
Integrations             none

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

when 404.astro is provided

going to /404 in the browser will lead to a 500 with the following error printed in the console

13:32:53 [ERROR] TypeError: mod.page is not a function
    at NodeApp.render (file:///home/nova/Downloads/absent-axis/dist/server/chunks/_@astrojs-ssr-adapter_DNZPGUso.mjs:4695:55)
    at async file:///home/nova/Downloads/absent-axis/dist/server/chunks/_@astrojs-ssr-adapter_DNZPGUso.mjs:5173:24
    at async file:///home/nova/Downloads/absent-axis/dist/server/chunks/_@astrojs-ssr-adapter_DNZPGUso.mjs:5206:7

this only happens when running server.mjs (note this is the server.mjs provided in the docs for astro/node)

What's the expected result?

allowing the middleware to handle the 404

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-xdbdlg1n?file=server.js

Participation

  • I am willing to submit a pull request for this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs triageIssue needs to be triaged

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions