Home / Notes /

Why my sign-in apps left the main domain

Serving every app under one address looked tidy. It also put my private tools and my public pages inside the same security boundary.

For a while, everything I built lived under one address. The portfolio sat at the root, the movie catalog at /stream, and each private tool at its own path. Vercel rewrites make this easy: the main site quietly proxies a path to another deployment, and the visitor never sees a second domain.

It looked tidy. It was also wrong for anything with a sign-in.

What the browser actually protects

A browser decides what a page may touch by origin: scheme, host and port. The path is not part of it. So thescorpia.com/ and thescorpia.com/some-app are the same place as far as the browser's rules go, even when two separate deployments answer them.

Two things followed from that.

  • The session cookie went everywhere. The app set its cookie with Path=/, so the browser attached it to every request on the domain, including requests to /stream, a public app that had no business seeing it.
  • Any script on the domain could act as me. A script on the portfolio and a script inside the private app shared an origin. If one third-party library on the public pages were ever compromised, it could call the private app's API with my session and read the answers.

Nothing was exploited. But "safe as long as every script on every public page behaves" is not a boundary. It is a hope.

The change

  • Each app with a sign-in now runs on its own origin, the address of its own deployment.
  • The main domain keeps the short address, but as a 307 redirect instead of a rewrite. The short link still works; it hands the browser over instead of proxying.
  • The auth library's base URL points at the new origin, so cookies are issued there and nowhere else.
  • /stream has no sign-in and holds no private data, so it stays a rewrite.

In vercel.json the difference is one block moving from rewrites to redirects:

{ "source": "/minutes-ai/:path*",
  "destination": "https://scorpia-minutes.vercel.app/minutes-ai/:path*",
  "permanent": false }

What it cost

  • The address bar changes after the redirect. The app no longer looks like part of the main site.
  • Cookies do not move between origins, so every session had to sign in again.
  • Each app now needs its own settings for anything tied to an address: the auth base URL, allowed origins, storage rules.

That is a fair price. The public pages can now carry whatever scripts they need, and none of them can reach a signed-in session.

The rule I keep

A path is a label. An origin is a wall. Anything that holds a session gets its own wall.

The second half of this work was locking down the public side, which is in the note about the Content-Security-Policy.