Skip to content

feat(auth): return to the requested page after login - #7520

Open
macko911 wants to merge 2 commits into
masterfrom
matej/nan-6573-keep-the-intended-destination-when-a-logged-out-user-opens-a
Open

macko911 wants to merge 2 commits into
masterfrom
matej/nan-6573-keep-the-intended-destination-when-a-logged-out-user-opens-a

Conversation

@macko911

@macko911 macko911 commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Context

Open a dashboard link while logged out — say app.nango.dev/team/billing — and you get sent to the login page. Log in and you land on the dashboard home page instead of the page the link pointed at, so you navigate there yourself.

Session cookies last 7 days, and people open emailed links days after they arrive. The session is usually gone by then, so this is the normal case rather than a rare one. It came up with the invite link in the join-request email.

The server side already worked, MFA step included. Nothing recorded where you were headed.

Changes

  • When PrivateRoute sends a logged-out user to the login page, it now adds the page they asked for as ?next=. The login page already passes that on as returnTo.
  • The 1024-character limit moves out of the signin request schema into safeReturnTo, so a longer destination falls back to / instead of failing the request and blocking login. The Logs page can put enough filters in the URL to go over it.

Fixes NAN-6573

Testing

On the preview, logged out, open /team/billing or /dev/logs?states=failed. Log in and you should land on that URL, query string included. Open / logged out and you get a plain /signin with no next.

Nothing to screenshot; only where you end up changes.

Follow-ups

  • Logging in with Google still loses the destination; the OAuth state has nowhere to carry it. Handled by the stacked PR.

A logged-out user opening a dashboard link was bounced to /signin and
then dropped on the environment home, losing the destination the link
carried. PrivateRoute now puts the current location on the bounce as
?next=, which Signin already forwards as returnTo.

The 1024 cap moves from the signin request schema into safeReturnTo, so
an over-long destination resolves to / instead of failing the request
and blocking login outright.
@linear-code

linear-code Bot commented Sep 14, 2026

Copy link
Copy Markdown

NAN-6573

@github-actions

github-actions Bot commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Preview Deploys

Preview Status URL Deploy Logs Last Updated
Webapp ✅ Ready Preview URL Deploy Logs 14 Sept 2026, 10:18 UTC
Storybook ✅ Ready Preview URL Deploy Logs 14 Sept 2026, 10:18 UTC

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 6 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread packages/webapp/src/utils/routes.ts
The length check reads plainly on its own, and why the cap moved out of
the request schema belongs in the commit that moved it.
@macko911
macko911 deployed to development September 14, 2026 10:15 — with GitHub Actions Active
@macko911
macko911 deployed to development September 14, 2026 10:15 — with GitHub Actions Active
@macko911
macko911 marked this pull request as ready for review September 14, 2026 10:16
@macko911
macko911 requested review from a team and agusayerza September 14, 2026 10:26
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.

1 participant