Skip to content

Remove trailing slashes from Next.js routes#1724

Open
paustint wants to merge 1 commit into
mainfrom
chore/remove-trailing-slash
Open

Remove trailing slashes from Next.js routes#1724
paustint wants to merge 1 commit into
mainfrom
chore/remove-trailing-slash

Conversation

@paustint
Copy link
Copy Markdown
Contributor

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.

Copilot AI review requested due to automatic review settings May 11, 2026 03:21
return next();
}
const query = req.url.slice(req.path.length);
res.redirect(301, newPath + query);
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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: false and update server-side static hosting to serve *.html with 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);
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

Successfully merging this pull request may close these issues.

3 participants