withastro / astro

The web framework for content-driven websites. ⭐️ Star to support our work!
https://astro.build
Other
46.78k stars 2.48k forks source link

Astro actions cause warning in dev mode for static pages #11099

Closed Trombach closed 5 months ago

Trombach commented 5 months ago

Astro Info

Astro                    v4.8.6
Node                     v21.6.0
System                   Linux (x64)
Package Manager          pnpm
Output                   hybrid
Adapter                  @astrojs/vercel/serverless
Integrations             @astrojs/tailwind
                         @astrojs/svelte
                         @astrojs/mdx
                         @astrojs/react
                         adds-to-head
                         @astrojs/sitemap

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

No response

Describe the Bug

After adding Astro actions and using it for my contact form, I've noticed that there is a new warning on the console.

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.

I am not using Astro.request.headers anywhere in my code so I wasn't sure what was going on. I ran a git bisect and confirmed that the commit which introduced this to my code is https://github.com/Trombach/astro-homepage/commit/dc552badf9dc627f607f595474b929cb441f255e in my homepage repo (which added Astro actions). These warning messages are shown whenever I navigate to a statically built page and opting this page into prerendering removes the warning. You can see this behaviour in the attached stackblitz

What's the expected result?

No warning should show for prerendered pages

Link to Minimal Reproducible Example

https://stackblitz.com/edit/withastro-astro-y37vny?file=src%2Fpages%2Faction.astro

Participation

Trombach commented 5 months ago

I just noticed I'm also getting the same error on every static page when running astro build (screenshot from vercel build) image

florian-lefebvre commented 5 months ago

This has been discussed on discord by the support patrol and this is caused by the Actions middleware retrieving a header so the warning is triggered on every static page

Trombach commented 5 months ago

fixed in #11111 (that number 😮). So closing it