Astro Info
Astro v6.0.3
Vite v7.3.1
Node v22.22.0
System Linux (x64)
Package Manager npm
Output static
Adapter none
Integrations none
If this issue only occurs in one browser, which browser is a problem?
n/a
Describe the Bug
Astro.url returns the URL of the current page when rendering.
In Astro 6, if you set build: { format: "file" } in the Astro configuration, this URL is incorrect at build time.
For src/pages/index.astro, the following values of Astro.url.pathname are observed:
- In
astro dev: /
- In
astro build: /.html
What's the expected result?
In Astro 5, the value of Astro.url.pathname is / for both dev and build.
I’m not 100% sure if the correct value here should in fact be /index.html given the configuration of build: { format: "file" } or if the Astro 5 behaviour was correct.
But either way, /.html is definitely incorrect and the inconsistency between dev and build is guaranteed to cause headaches for users. Unless there were intentional changes to Astro.url in v6, the simplest course of action is probably to restore the v5 behaviour and then consider for the future if we want to change what the output should be.
Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-h6fxxxfc?file=astro.config.mjs&file=src%2Fpages%2Findex.astro
Participation
Astro Info
If this issue only occurs in one browser, which browser is a problem?
n/a
Describe the Bug
Astro.urlreturns the URL of the current page when rendering.In Astro 6, if you set
build: { format: "file" }in the Astro configuration, this URL is incorrect at build time.For
src/pages/index.astro, the following values ofAstro.url.pathnameare observed:astro dev:/astro build:/.htmlWhat's the expected result?
In Astro 5, the value of
Astro.url.pathnameis/for both dev and build.I’m not 100% sure if the correct value here should in fact be
/index.htmlgiven the configuration ofbuild: { format: "file" }or if the Astro 5 behaviour was correct.But either way,
/.htmlis definitely incorrect and the inconsistency between dev and build is guaranteed to cause headaches for users. Unless there were intentional changes toAstro.urlin v6, the simplest course of action is probably to restore the v5 behaviour and then consider for the future if we want to change what the output should be.Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-h6fxxxfc?file=astro.config.mjs&file=src%2Fpages%2Findex.astro
Participation