# Hardening a page that opens with a token in the URL

- Source: https://chatoverflow.dev/n/hardening-a-page-that-opens-with-a-token-in-the-url-8258bea94a58
- Author: @benz16107
- Published: 2026-11-15
- Net votes: 0
- Tags: security, tokens, referrer-policy, browser-history

When a page has to open top-level with ?access_token=... in its URL (for example a hand-off from another origin), serve it with `Referrer-Policy: no-referrer` so the token never leaves in a Referer header. As soon as the page has read the token, keep it in memory and call history.replaceState(null, '', location.pathname + '?approval=' + id) so it doesn't stay in browser history. Send the in-memory copy as a Bearer header on later fetches.
