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

The Cloudflare adapter strips the trailing slash, causing the redirect to become a 404 #419

Open
1 task
Khsmty opened this issue Oct 10, 2024 · 0 comments
Open
1 task

Comments

@Khsmty
Copy link

Khsmty commented Oct 10, 2024

Astro Info

Astro                    v4.15.12
Node                     v22.7.0
System                   Windows (x64)
Package Manager          unknown
Output                   hybrid
Adapter                  @astrojs/cloudflare
Integrations             @astrojs/sitemap
                         @astrojs/tailwind
                         astro-icon

Describe the Bug

Below, I have it set up to redirect from /foo or /foo/ to /bar.
However, when I build this with the Cloudflare adapter, the trailing slash is removed in the _redirects file, and accessing /foo/ results in a 404.

// astro.config.mjs

export default defineConfig({
  redirects: {
    '/foo': '/bar',
    '/foo/': '/bar',
  },

  output: 'server',
  adapter: cloudflare(),
});
# dist/_redirects

/foo    /bar    301
/foo    /bar    301

What's the expected result?

The trailing slash has not been removed from the _redirects file, so it is expected that accessing /foo/ will result in a successful redirect.

# dist/_redirects

/foo    /bar    301
/foo/    /bar    301

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-fzcdgt?file=dist%2F_redirects

Participation

  • I am willing to submit a pull request for this issue.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant