-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Closed
Labels
needs triageIssue needs to be triagedIssue needs to be triaged
Description
Astro Info
Astro v4.15.8
Node v18.20.3
System Linux (x64)
Package Manager npm
Output static
Adapter none
Integrations none
If this issue only occurs in one browser, which browser is a problem?
n/a — Astro dev server issue
Describe the Bug
In dev mode, middleware is not run for URLs that 404. We hit this with Starlight’s new locals.t() function as it causes Starlight code to error when trying to call t() which is undefined.
In the minimal repro the following set-up is in place:
src/middleware.tsattaches a simple function tocontext.locals.src/pages/index.astroandsrc/pages/404.astroboth use this function to render some text.- Visiting
/works as expected — theAstro.locals.t()call renders some text. - Visiting other routes, which trigger the custom 404, cause a
Astro2.locals.t is not a functionerror to be thrown.
What's the expected result?
Locals set by middleware should be available in a custom 404 as they are in a regular page.
Link to Minimal Reproducible Example
Participation
- I am willing to submit a pull request for this issue.
Metadata
Metadata
Assignees
Labels
needs triageIssue needs to be triagedIssue needs to be triaged