Closed florian-lefebvre closed 8 months ago
I expect such configuration to not throw this error.
That's a bit generic as an expectation. Since both configurations go in conflict (astro and vercel), which one should win?
Ah I see what you mean. I guess I'd expect vercel to redirect from /blog
to /blog/
and Astro to return a 404 if /blog
is ever reached?
Or should I remove the trailingSlash config in Astro to let Vercel handle it?
IMHO, a configuration like this should error and never build, because Astro and Vercel adapter don't know what the user wants, due to conflicting options.
Although, I'm not sure if the adapter ever reads vercel.json
. If it does, it should do this check
Okay so after thinking about it, I ended up doing this:
const DEV = process.env.NODE_ENV === "development"
export default defineConfig({
trailingSlash: DEV ? 'always' : 'ignore'
})
This way I get a consistent behavior between dev and prod. I think it could be great if the vercel integration looked for a vercel.json
in the root and based on trailingSlash
, overwrites it using updateConfig
. Tell me if that sounds good and I could submit a PR
Okay so after thinking about it, I ended up doing this:
const DEV = process.env.NODE_ENV === "development" export default defineConfig({ trailingSlash: DEV ? 'always' : 'ignore' })
This way I get a consistent behavior between dev and prod. I think it could be great if the vercel integration looked for a
vercel.json
in the root and based ontrailingSlash
, overwrites it usingupdateConfig
. Tell me if that sounds good and I could submit a PR
That sounds like a reasonable approach to me! I would also add a warning while doing so, because we still don't know which trailing slash is the correct one and users should know that the adapter will use the one option defined in the vercel.json.
Sorry for digging up an old issue, but I'm confused about some details, maybe someone could help me clear them up? I wanted to set this up exactly like OP mentioned:
trailingSlash
option "Set the route matching behavior of the dev server" – I didn't expect this to have any effect on anything but the dev server/blog
to /blog/
in case it's missing somewhere and for consistent links, also in regards to SEO indexing and duplicatesSo I configured Astro to use trailingSlash: "always"
and vercel trailingSlash: true
. How would this conflict? Don't these configs try to achieve the same goal, just in different envs?
Does the Astro config affect more than the dev server, contrary to the docs? I could understand it if the settings were sth. like Astro trailingSlash: "always"
and vercel trailingSlash: false
which sounds like an actual conflict to me.
I must be missing sth., I'd be grateful for any input here 😅
Indeed both conflict! In the linked PR, if you are in such situation (in build only I think but not sure), the adapter will warn you and update the astro config to trailingSlash: 'ignore'
Astro Info
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
Using the vercel adapter, setting
trailingShlash: "always"
(astro config) +"trailingSlash": true
(vercel config) can make some routes to throw aERR_TOO_MANY_REDIRECTS
. For this repro, it happens on the/blog/
page but on another private project I'm working on, it does it for the favicon and sitemap generated urls.https://astro-too-many-redirects-repro.vercel.app/blog/
What's the expected result?
I expect such configuration to not throw this error.
Link to Minimal Reproducible Example
https://github.com/florian-lefebvre/astro-too-many-redirects-repro
Participation