astro ssg routing bug

a routing bug in astro's ssg mode

when
30 May 2026
labels
astro · routing · ssg · bug
reading
1 min read

a moment that made me do some googling and some vibe coding

historically, nginx and other classic web servers handle directories and files differently

when /about is requested:

1. /about/index.html — if the server can't find a file but finds a directory with the same name, it redirects to /about/ and looks for index.html there
2. about.html — served directly

in astro I added client-side routing while the app itself ran as SSG, so the first request had to get a ready-made page and later navigation had to be handled on the client

and then the redirects caused a reload and broke client-side navigation, all because of astro's default build format (see screenshot 1)

fixed it by changing the build format with format: file (see screenshot 2)

p.s. surprisingly, vercel has learned to resolve paths for every framework, and everything worked there out of the box

p.p.s. an interesting article, not exactly my case but close https://aaronjbecker.com/posts/astro-nginx-url-trailing-slashes/

screenshot 1
screenshot 1