Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic routes in Astro redirects error #8639

Closed
1 task
delucis opened this issue Sep 22, 2023 · 1 comment · Fixed by #8647
Closed
1 task

Dynamic routes in Astro redirects error #8639

delucis opened this issue Sep 22, 2023 · 1 comment · Fixed by #8647
Labels
- P4: important Violate documented behavior or significantly impacts performance (priority) feat: redirects Related to the redirects feature (scope)

Comments

@delucis
Copy link
Member

delucis commented Sep 22, 2023

Astro Info

(run on StackBlitz)

Astro                    v3.1.2
Node                     v16.20.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 supports a redirects field in astro.config. According to our docs this should be able to support dynamic routes:

Dynamic routes are allowed as long as both the new and old routes contain the same parameters

I’m seeing errors for each of the following cases:

  redirects: {
    '/old/[...spread]': '/new/[...spread]',
    '/old/[dynamic]': '/[dynamic]',
    '/old/[dynamic]/[route]': '/[dynamic]/[route]',
  }

In each case, attempting to load a route from one of the /old/ paths, throws:

getStaticPaths() function is required for dynamic routes. Make sure that you export a getStaticPaths function from your dynamic route.

The dynamic routes at the new location each contain getStaticPaths().

What's the expected result?

Dynamic redirects containing the same parameters redirect to the new location as expected.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-gjbu5b?file=astro.config.mjs

Participation

  • I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Sep 22, 2023
@lilnasy lilnasy added - P4: important Violate documented behavior or significantly impacts performance (priority) feat: redirects Related to the redirects feature (scope) and removed needs triage Issue needs to be triaged labels Sep 23, 2023
@lilnasy
Copy link
Contributor

lilnasy commented Sep 23, 2023

Just to confirm, this is a dev-mode only issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P4: important Violate documented behavior or significantly impacts performance (priority) feat: redirects Related to the redirects feature (scope)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants