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

Astro redirects not working #7322

Closed
1 task
Erlandas opened this issue Jun 7, 2023 · 4 comments · Fixed by #7342 or #7701
Closed
1 task

Astro redirects not working #7322

Erlandas opened this issue Jun 7, 2023 · 4 comments · Fixed by #7342 or #7701
Assignees
Labels
- P4: important Violate documented behavior or significantly impacts performance (priority) feat: ssr Related to SSR (scope)

Comments

@Erlandas
Copy link

Erlandas commented Jun 7, 2023

What version of astro are you using?

2.6.1

Are you using an SSR adapter? If so, which one?

Vercel

What package manager are you using?

yarn

What operating system are you using?

Windows

What browser are you using?

Chrome

Describe the Bug

Tried out new experimental redirects.

experimental: {
    redirects: true
  },
redirects: {
    '/a': '/b'
  }

Went trough all paths possible (for both new page and old page with slash and without) Yet visiting page "/a" no redirects being made (both in dev and production).

Link to Minimal Reproducible Example

https://stackblitz.com/edit/withastro-astro-njit3y

Participation

  • I am willing to submit a pull request for this issue.
@jlarmstrongiv
Copy link

The types and validation for redirects are also incorrect

@matthewp matthewp self-assigned this Jun 8, 2023
@matthewp matthewp added the - P4: important Violate documented behavior or significantly impacts performance (priority) label Jun 8, 2023
@matthewp
Copy link
Contributor

matthewp commented Jun 8, 2023

I can recreate the dev problem. Fixing now.

@pijusz
Copy link

pijusz commented Jun 12, 2023

Would like to reopen this @matthewp
In astro docs, redirect with non-301 status doesn't work.

Goal is to be able to redirect with parameters status 308 (f.e. /b?type=b, /a?type=b)

  output: "hybrid",
  adapter: vercel(),
  experimental: {
    redirects: true,
  },
  redirects: {
    "/b": {
      destination: "/a",
      status: 308,
    },
  },

received error:

[config] Astro found issue(s) with your configuration:
  ! redirects./b  Expected string, received object.

@bluwy
Copy link
Member

bluwy commented Jul 17, 2023

Can confirm this is still happening. I'm refactoring some tests that now validates the config, and it fails with the error too. We need to fix the validation here:

redirects: z.record(z.string(), z.string()).default(ASTRO_CONFIG_DEFAULTS.redirects),

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: ssr Related to SSR (scope)
Projects
None yet
6 participants