-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Description
Astro Info
Astro v5.15.3
Vite v6.4.1
Node v20.19.1
System Linux (x64)
Package Manager npm
Output static
Adapter @astrojs/node (v9.5.0)
Integrations none
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
Given this astro.config.mjs...
import { defineConfig } from 'astro/config';
import node from '@astrojs/node';
export default defineConfig({
// Output defaults to "static" but an adapter is configured,
// so some pages can use `export const prerender = false`
adapter: node({
mode: 'standalone',
}),
redirects: {
// For illustration purposes, ./src/pages/foo/baz/[...aAndB].astro exists as a dynamic page.
// However, the same issue arises if the page does not exist.
'/foo/bar/[a]/[b]': '/foo/baz/[a]/[b]',
},
});... the build command astro build will fail with this error:
15:20:25 [ERROR] [build] Failed to call getStaticPaths for /foo/bar/[a]/[b]
[GetStaticPathsRequired] `getStaticPaths()` function is required for dynamic routes. Make sure that you `export` a `getStaticPaths` function from your dynamic route.
Hint:
See https://docs.astro.build/en/guides/routing/#dynamic-routes for more information on dynamic routes.
If you meant for this route to be server-rendered, set `export const prerender = false;` in the page.
Error reference:
https://docs.astro.build/en/reference/errors/get-static-paths-required/
Location:
/foo/bar/[a]/[b]:0:0
Stack trace:
at AstroError (file:///home/projects/github-axtnv9fr-q4kj3lng/node_modules/astro/dist/core/errors/errors.js:37:5)
at callGetStaticPaths (file:///home/projects/github-axtnv9fr-q4kj3lng/node_modules/astro/dist/core/render/route-cache.js:36:26)
at generatePage (file:///home/projects/github-axtnv9fr-q4kj3lng/node_modules/astro/dist/core/build/generate.js:196:25)
This is a follow-up to #14054. As far as I can parse it, PR #14170 created a partial fix by looking up the destination page and checking whether it is dynamically rendered. However, this fails if the destination page uses the spread syntax ([...aAndB].astro) or does not exist.
This configuration worked with Astro 5.9 and was regressed by PR #13924.
What's the expected result?
I'd expect the redirection to not be prerendered when it contains parameters, regardless of the default prerender mode , the existence of redirect target, or whether it is a prerendered page. Even if we could use the getStaticPaths method of all routes, including using the spread syntax to correctly determine and prerender all possible redirects, local redirects could point to pages not built by Astro that require a dynamic redirect.
Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-axtnv9fr-ddetrewj?file=astro.config.mjs
Participation
- I am willing to submit a pull request for this issue.