Skip to content

Move authenticated routes to app.nemar.org #47

Closed

Description

@neuromechanist

Goal

Split the website surface across two custom domains on one Astro codebase so the session cookie stays host-only and never attaches to public subdomains.

  • nemar.org — public marketing surface (anonymous, cacheable).
  • app.nemar.org — authenticated surface (cookies, no edge cache).

Decision context lives in .context/handoff-auth-backend.md on the local feature/auth-backend-pending branch.

Why

A cookie scoped to .nemar.org attaches to every request to api.nemar.org, data.nemar.org, docs.nemar.org, and any future discuss.nemar.org. That is wasteful (every byte-range raw.set fetch carries it) and widens the blast radius of any subdomain compromise. Host-only cookie on app.nemar.org solves it.

This must be applied before the backend (nemarOrg/nemar-cli#569) issues its first prod cookie, because changing cookie domain later logs everyone out.

Surface allocation

app.nemar.org (authenticated):

  • /login, /login/verify, /login/pending
  • /welcome
  • /dashboard
  • /upload, /upload/success
  • /admin/*
  • /settings
  • /dataset/[id]/collaborators
  • /api/auth/*, /api/admin/* proxies

nemar.org (marketing):

  • /, /about, /support, /community, /citation-dashboard
  • /discover
  • /dataset/[id] (not /collaborators)
  • /docs/*
  • /signup (CLI-deferral page)
  • 404

Acceptance

  • Middleware reads Astro.url.hostname and 301-redirects mismatches across the two production hosts.
  • On nemar.org, middleware never calls /auth/me and never sets Astro.locals.session.
  • Marketing nav shows no UserMenu; "Sign in" link points at https://app.nemar.org/login.
  • App nav shows UserMenu + "Explore datasets" link to https://nemar.org/discover.
  • *.pages.dev previews and localhost keep current single-host behavior so QA stays cheap.
  • src/middleware.test.ts covers both redirect directions and the single-host passthrough.
  • Custom domain app.nemar.org is added to the Cloudflare Pages project (documented in AGENTS.md; manual dashboard step).
  • Backend contract in .context/handoff-auth-backend.md cross-checked against nemar-cli#569 work-in-progress so cookie Domain=app.nemar.org is set there (not .nemar.org).

Out of scope

  • The nemar-cli#569 backend itself.
  • Forum / /discuss surface — separate future decision.
  • Splitting into two Pages projects (single project, two custom domains is the v1).

Activity

  1. added a commit that references this issue on May 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions