-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Astro.url regression in v6 with build.format: "file" #15866
Description
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
- I am willing to submit a pull request for this issue.