Return to the settings page the user came from after disconnecting

Previously always redirected to /settings (which resolves to /settings/profile).
Now reads the Referer header and redirects back to the originating /settings/*
page, defaulting to /settings/connections if no valid referer.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Ullrich Schäfer 2026-05-23 20:46:29 +02:00
parent a181dfe6b8
commit 12371d8c89
No known key found for this signature in database
GPG key ID: A32FF691A0F752D9

View file

@ -14,5 +14,9 @@ export async function action({ params, request }: Route.ActionArgs) {
// the local row regardless of revoke outcome. Imported activities are
// retained (FK is set null on imports.activityId, not cascaded).
await unlinkByUserProvider(user.id, manifest.id);
return redirect("/settings");
const referer = request.headers.get("referer");
const url = referer ? new URL(referer) : null;
const back = url?.pathname.startsWith("/settings") ? url.pathname : "/settings/connections";
return redirect(back);
}