You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When Astro builds a site with the Netlify adapter on static mode, it is processing the middleware when it is building static pages. This occurs regardless of whether or not edgeMiddleware: true in the adapter configuration. When the middleware uses any of the server-side headers or request methods, it outputs the message:
Astro.request.headers was used when rendering the route src/pages/*. Astro.request.headers is not available on prerendered pages. If you need access to request headers, make sure that the page is server-rendered using export const prerender = false; or by setting output to "server" in your Astro config to make all your pages server-rendered by default.
This is expected if normal middleware is elected. However, with edge middleware, middleware will run even on the static pages. Example is attached.
What's the expected result?
Ultimately if edgeMiddleware: true in the astro.config.mjs, this message should not output at all. The headers and request info are able to be accessed in edgeMiddleware even on static pages as if they were server rendered.
I am willing to submit a pull request for this issue.
The text was updated successfully, but these errors were encountered:
JacobNWolf
changed the title
@astrojs/netlify Adapter processes middlware when building static pages
@astrojs/netlify Adapter processes middleware when building static pages
Jan 11, 2025
JacobNWolf
changed the title
@astrojs/netlify Adapter processes middleware when building static pages
@astrojs/netlify Adapter processes edge middleware when building static pages
Jan 11, 2025
Astro Info
Describe the Bug
When Astro builds a site with the Netlify adapter on static mode, it is processing the middleware when it is building static pages. This occurs regardless of whether or not
edgeMiddleware: true
in the adapter configuration. When the middleware uses any of the server-sideheaders
orrequest
methods, it outputs the message:This is expected if normal middleware is elected. However, with edge middleware, middleware will run even on the static pages. Example is attached.
What's the expected result?
Ultimately if
edgeMiddleware: true
in theastro.config.mjs
, this message should not output at all. The headers and request info are able to be accessed in edgeMiddleware even on static pages as if they were server rendered.Link to Minimal Reproducible Example
https://stackblitz.com/edit/withastro-astro-3u3rtsrg?file=src%2Fmiddleware.ts
Participation
The text was updated successfully, but these errors were encountered: