Remove trailing slashes from Next.js routes#1724
Open
paustint wants to merge 1 commit into
Open
Conversation
| return next(); | ||
| } | ||
| const query = req.url.slice(req.path.length); | ||
| res.redirect(301, newPath + query); |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR standardizes Jetstream URLs by removing trailing slashes across the Landing app (Next.js export), API-generated redirect URLs, docs links, and E2E route matchers, to improve routing consistency and avoid duplicate URLs.
Changes:
- Switch Landing Next.js export to
trailingSlash: falseand update server-side static hosting to serve*.htmlwith a trailing-slash redirect. - Update API redirect URLs and various hard-coded external links to remove trailing slashes.
- Update Playwright E2E route patterns/assertions to match the new non-trailing-slash URLs.
Reviewed changes
Copilot reviewed 24 out of 24 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| scripts/stripe-update-billing-portal-config.mjs | Updates Stripe portal legal URLs to remove trailing slashes. |
| libs/test/e2e-utils/src/lib/pageObjectModels/AuthenticationPage.model.ts | Adjusts auth route helpers to match non-trailing-slash URLs and wildcard matching. |
| libs/shared/ui-router/src/lib/ui-router.ts | Updates external route constants to non-trailing-slash URLs. |
| apps/landing/utils/environment.ts | Updates Landing AUTH route constants for login/signup without trailing slashes. |
| apps/landing/pages/privacy/index.tsx | Updates a legal/vendor link to remove trailing slash. |
| apps/landing/next.config.js | Sets trailingSlash: false for Next.js export output. |
| apps/jetstream/src/app/components/settings/Settings.tsx | Removes trailing slash from the goodbye redirect. |
| apps/jetstream-e2e/src/tests/authentication/team/team.spec.ts | Updates URL expectations and wait patterns for MFA enrollment routes. |
| apps/jetstream-e2e/src/tests/authentication/external-auth/external-auth-logged-in.spec.ts | Updates desktop/web-extension auth URLs to remove trailing slashes. |
| apps/docs/src/shared-components/RequiresProPlan.tsx | Updates pricing link to remove trailing slash. |
| apps/docs/docusaurus.config.ts | Updates footer legal links to remove trailing slashes. |
| apps/docs/docs/team-management/team-management.mdx | Updates pricing link to remove trailing slash. |
| apps/docs/docs/getting-started/security.mdx | Updates legal resource links to remove trailing slashes. |
| apps/docs/docs/getting-started/overview.mdx | Updates signup/pricing links to remove trailing slashes. |
| apps/docs/docs/getting-started/desktop-app.mdx | Updates desktop download link to remove trailing slash. |
| apps/api/src/main.ts | Serves Landing export with extensions:['html'], adds trailing-slash redirect middleware, and simplifies 404.html loading for the new export mode. |
| apps/api/src/app/utils/response.handlers.ts | Updates auth logout redirect URLs to remove trailing slashes. |
| apps/api/src/app/routes/route.middleware.ts | Adds stripTrailingSlashRedirect middleware for GET/HEAD requests. |
| apps/api/src/app/routes/redirect.routes.ts | Updates redirect to login URL to remove trailing slash. |
| apps/api/src/app/controllers/web-extension.controller.ts | Updates login redirect to /auth/login (no trailing slash). |
| apps/api/src/app/controllers/oauth.controller.ts | Updates oauth-link redirect URLs to remove trailing slashes. |
| apps/api/src/app/controllers/desktop-app.controller.ts | Updates login redirect URL to remove trailing slash. |
| apps/api/src/app/controllers/canvas.controller.ts | Updates canvas-auth redirect URL to remove trailing slash. |
| apps/api/src/app/controllers/auth.controller.ts | Updates login redirect path returned in JSON to remove trailing slash. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+97
to
+105
| if (req.path === '/' || !req.path.endsWith('/')) { | ||
| return next(); | ||
| } | ||
| const newPath = pathPosix.normalize(req.path.replace(/\/+/g, '/')).replace(/\/$/, ''); | ||
| if (!newPath.startsWith('/') || newPath.startsWith('//')) { | ||
| return next(); | ||
| } | ||
| const query = req.url.slice(req.path.length); | ||
| res.redirect(301, newPath + query); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Eliminate trailing slashes from various Next.js routes and URLs to ensure consistency and improve routing behavior. This change enhances the application's URL structure.