Skip to content

Astro.request.headers access when configure allowedDomains for prerendered pages #17077

Description

@jwundrak

Astro Info

Astro                    v6.4.6
Node                     v22.22.3
System                   Linux (x64)
Package Manager          unknown
Output                   server
Adapter                  @astrojs/node
Integrations             none

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

No response

Describe the Bug

For my hybrid-page (output server with some static pages) I need to set security.allowedDomains.

Every static page (export const prerender=true) produce a warning:

[WARN] `Astro.request.headers` was used when rendering the route `src/pages/index.astro'`. `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.

In the end this is only a warning, that can be ignored, but it is hard to find "real" issues, if there is accidentally a access to the headers for static pages.

The warning is also visible in dev-server and access is from the #applyForwardedHeader

Reproduction link is the minimal example with output: 'server', security.allowedDomains and page/index.ts with prerender=true

What's the expected result?

Static pages should not create a warning from the allowedDomain check. Maybe the check can competely skip for prerendered pages?

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-bfeujqd3

Participation

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    - P3: minor bugAn edge case that only affects very specific usage (priority)pkg: astroRelated to the core `astro` package (scope)

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions