-
-
Notifications
You must be signed in to change notification settings - Fork 38
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
Routing too many redirects when using the config.json file generated by the Vercel adapter #418
Comments
@yuhangch the link you provided isn't a valid reproduction |
Sorry, I just disable the Vercel Authentication There is a capture: 20241009_193142.mp4 |
@yuhangch we need a reproduction which we can debug. Please the stackblitz URL provided |
Okay got it. I can't completely reproduce the issue on Stackblitz because the behavior is different on the dev server compared to when deployed with the Vercel adapter. Below is the simplest code. I have still deployed it to a sample project on Vercel.
|
It's okay, we can deploy it ourselves on Vercel |
I believe I just encountered this same issue. The regression appears to be introduced as of I have a route served by a rest param for an SSR page at ---
import PackagePageLayout from '@/layouts/pkg/PackagePageLayout.astro';
import { getEntry } from 'astro:content';
const { slug } = Astro.params;
if (!slug) {
return new Response('Not found', { status: 404 });
}
const splitSlug = slug.split('/');
if (!slug.endsWith('/')) {
// Permanent redirect to the canonical URL with trailing slash:
const url = new URL(Astro.request.url);
url.pathname = `${url.pathname}/`;
return Astro.redirect(url, 301);
}
// fetch content and render ...
---
<html /> With the Locally, this still works fine, it's only once deploying to vercel that it breaks. |
Astro Info
Describe the Bug
Configuration:
trailingSlash: 'always'
inastro.config.mjs
build: { format: 'directory' }
Problem:
When visiting the
/docs/
route, I encounter a "Redirected you too many times" error.Details:
The directory structure is as follows:
The
config.json
file generated by the adapter looks like this:Issue:
/docs/
route appears to redirect indefinitely, It seems the redirection rules are creating a loop for this route.When delete
trailingSlash: 'always'
inastro.config.mjs
, the redirect in config.json was not be generated, and/docs/
works well.What's the expected result?
The
/docs/
route should resolve correctly without an infinite redirect loop withtrailingSlash: 'always'
config.Link to Minimal Reproducible Example
http://yuhang-ch-git-loop-redirect-yuhang-chens-projects.vercel.app/docs/
Participation
The text was updated successfully, but these errors were encountered: