Astro: Redirect routes cause some directories to fail matching on S3
bayssmekanique opened this issue · comments
Zach Cardoza commented
The issue appears to be that the redirect routes in the meta file cause a tree branch in the CF Function matching logic which terminates without looping back to the catch all slug.
Ref sst.buildMeta.json
:
{
"domainName": "",
"deploymentStrategy": "regional",
"responseMode": "buffer",
"outputMode": "hybrid",
"pageResolution": "directory",
"trailingSlash": "ignore",
"serverBuildOutputFile": "dist/server/entry.mjs",
"clientBuildOutputDir": "dist/client",
"clientBuildVersionedSubDir": "_astro",
"routes": [
...
{
"route": "/harrypedia/culture/contracts",
"type": "redirect",
"pattern": "/^\\/harrypedia\\/culture\\/contracts\\/?$/",
"redirectPath": "/harrypedia/magic/contracts/"
},
{
"route": "/harrypedia/magic/spells/patronus",
"type": "redirect",
"pattern": "/^\\/harrypedia\\/magic\\/spells\\/patronus\\/?$/",
"redirectPath": "/harrypedia/magic/spells/expecto_patronum/"
},
{
"route": "/[...slug]",
"type": "page",
"pattern": "/^(?:\\/(.*?))?\\/?$/",
"prerender": true
}
],
"serverRoutes": []
}
Zach Cardoza commented
While investigating this issue, I uncovered a change in the Astro routing priority logic which causes further issues in the route matching.
Ref: Astro #9439
The result is that redirects are now matching below spread routes which won't allow the redirect routes to be picked up correctly.
{
"route": "/",
"type": "page",
"pattern": "/^\\/$/",
"prerender": true
},
{
"route": "/[...slug]",
"type": "page",
"pattern": "/^(?:\\/(.*?))?\\/?$/",
"prerender": true
},
{
"route": "/blog/fourth-post",
"type": "redirect",
"pattern": "/^\\/blog\\/fourth-post\\/?$/",
"redirectPath": "/blog/third-post/"
},
{
"route": "/old-blog",
"type": "redirect",
"pattern": "/^\\/old-blog\\/?$/",
"redirectPath": "/blog"
},
{
"route": "/old-blog/[...slug]",
"type": "redirect",
"pattern": "/^\\/old-blog(?:\\/(.*?))?\\/?$/",
"redirectPath": "/blog/[...slug]"
}
Luke Schierer commented
the global routes option did not help.
Luke Schierer commented
I confirm that PR fixed this.