Closed mrcnski closed 8 months ago
Can confirm, running into the same issue right now.
Will be fixed by https://github.com/withastro/astro/pull/10196, sorry for the inconvenience. It's a bug with i18n in particular
Awesome! Sorry, I searched existing issues but didn't think to search PRs.
https://github.com/withastro/astro/pull/10196 has been merged
I've confirmed that this has been fixed as of 4.4.5, thanks everybody.
I just upgraded to 4.5.9 and I'm running into this issue. The warning is only for my prerendered pages. I have output: 'server'
can confirm this still is a problem with hybrid
, i18n
and such a .astro file:
---
import { getHeadersLocale } from '../utils/headersLocale'
const locale = getHeadersLocale(Astro.request.headers.get('accept-language') ?? 'en')
return Astro.redirect(`/${locale}`)
---
This is intentional. You can't read headers in a static page. We do this on purpose so that you don't rely on behavior that will lead to build-time and run-time differences.
@matthewp I'm not reading any headers though.
EDIT: I was reading headers.. sorry
---
import ThemeToggle from "./ThemeToggle";
const cookie = Astro.cookies.get("theme");
export const prerender = false;
---
<ThemeToggle themeCookie={cookie?.value} client:load />
I have a ThemeToggle component like this, this component is accessing cookie in headers. And my astro.config.mjs is output: hybrid
. This component runs on server instead of client as I've specified prerender=false
, but I still get the warning, and I thinks it's ok to access headers in this situation...
Hint: this error occurs on symbolic linked files too, even if prerender is set to false.
I encountered the same warning again in the latest update "4.16.1." I had to downgrade to "4.16.0" to make the warning disappear in a project created from scratch using bun create astro
.
Same here, running Astro on Cloudflare Workers. Just upgraded and started getting this warning. I also have an endpoint that started failing with this error on the server side:
(error) 12:28:48 [ERROR] TypeError: Can't modify immutable headers.
at setOriginHeader (_worker.js:163:25960)
at RenderContext.create (_worker.js:165:3228)
at async bn.render (_worker.js:180:186)
at async Object.fetch (_worker.js:180:5208)
(not sure if related or if this is a separate issue.) edit: separate issue: https://github.com/withastro/astro/issues/12201
Astro Info
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
Since upgrading to Astro 4.4.3 I'm getting this warning in the console:
What's the expected result?
I was not getting this warning on Astro 4.3.7.
I'm not doing anything with
headers
AFAIK, but it would be nice to have a trace to know where this warning is coming from.I tried for some time but I'm having trouble reproducing this on Stackblitz or in a fresh project. As mentioned above, a trace would be nice. My project is simple, my only dependencies are Astro and Typescript.
Link to Minimal Reproducible Example
https://stackblitz.com/see-above
Participation