Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.0.0-beta.8] Astro.request.headers warning when build output server with prerender #12459

Open
1 task
drithh opened this issue Nov 17, 2024 · 4 comments
Open
1 task
Labels
needs triage Issue needs to be triaged

Comments

@drithh
Copy link

drithh commented Nov 17, 2024

Astro Info

Astro                    v5.0.0-beta.8
Node                     v23.1.0
System                   macOS (arm64)
Package Manager          bun
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

[WARN] `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.

that warning will be shown on output mode server and there page with export const prerender = true;

What's the expected result?

The warning shouldn’t appear because I’m not accessing the headers in my code. This issue seems similar to what’s described here: withastro/astro#12069. but this issue only fix when output mode static

Link to Minimal Reproducible Example

https://github.com/drithh/astro-header-warning

Participation

  • I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Nov 17, 2024
@ematipico
Copy link
Member

ematipico commented Nov 18, 2024

@drithh please provide a valid reproduction, your astro info says you're using the node adapter, but reproduction doesn't have any

@ematipico ematipico added the needs repro Issue needs a reproduction label Nov 18, 2024
Copy link
Contributor

Hello @drithh. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with needs repro will be closed if they have no activity within 3 days.

@github-actions github-actions bot removed the needs triage Issue needs to be triaged label Nov 18, 2024
@mayank99
Copy link
Contributor

mayank99 commented Nov 19, 2024

Here's a minimal repro: 4.16.14 | 5.0.0-beta.10

20:52:45 [build] Building server entrypoints...
20:52:46 [vite] ✓ built in 1.07s
20:52:46 [build] ✓ Completed in 1.37s.

 prerendering static routes 
20:52:46 ▶ src/pages/index.astro
20:52:46   └─ /index.html20:52:46 [WARN] `Astro.request.headers` is unavailable in "static" output mode, and in prerendered pages within "hybrid" and "server" output modes. If you need access to request headers, make sure that `output` is configured as either `"server"` or `output: "hybrid"` in your config file, and that the page accessing the headers is rendered on-demand.
 (+27ms)
20:52:46 ✓ Completed in 189ms.

@ematipico ematipico added needs triage Issue needs to be triaged and removed needs repro Issue needs a reproduction labels Nov 19, 2024
@spaceemotion
Copy link

spaceemotion commented Nov 22, 2024

Just stumbled across this as well - but it only started to happen after I added the experimental container API (we needed to render a Content component to HTML). Not sure if I need to configure something in the container to make the warning go away.

Edit: I'm guessing this might have been fixed via #12498?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage Issue needs to be triaged
Projects
None yet
Development

No branches or pull requests

4 participants