Skip to content

Apex cutover: ww2 becomes nemar.org, legacy moves to ww1, legacy URLs must keep resolving #190

Closed

Description

@neuromechanist

Planning issue for the DNS cutover: ww2.nemar.org becomes the apex nemar.org, and the current legacy site moves to ww1.nemar.org.

The mechanical part is small. The part that needs care is legacy URL preservation — old NEMAR URLs are cited in published papers and cannot be allowed to dead-end.

1. Cutover mechanics

  • MARKETING_BASE_URL in src/lib/host.ts → https://nemar.org
  • site in astro.config.mjs → https://nemar.org (AGENTS.md says keep these in lockstep)
  • Attach the apex to the nemar-website Pages project (currently only ww2 and app are attached)
  • Add ww1.nemar.org to MARKETING_HOSTS? No — see §5. ww1 is a separate origin, not this build.
  • Decide what ww2.nemar.org does afterwards: 301 to apex is the clean answer, so the beta hostname stops competing as a duplicate.

2. Legacy dataset URLs → new dataset pages

The case that matters:

https://nemar.org/dataexplorer/detail?dataset_id=ds007964
        ↓
https://nemar.org/dataset/on007964

The mapping is verified, not assumed. Sampled 199 on* rows from the live catalog: every one has a source_id, and every one is digit-preserving (on007964 ⇄ ds007964). Zero mismatches.

$ curl -s 'https://api.nemar.org/datasets/on007964' | jq '{dataset_id, source, source_id}'
{ "dataset_id": "on007964", "source": "openneuro", "source_id": "ds007964" }

So ds\d{6} → on\d{6} is a safe string transform, with one caveat: it is only currently true. A future import that breaks the convention would silently send a cited URL to the wrong dataset, which is worse than a 404.

Suggested shape: transform optimistically (no API call, fast, cacheable), then handle the miss gracefully rather than serving a dead page — fall back to /discover?search=ds007964 so a reader of a 2024 paper still lands somewhere useful. Worth deciding explicitly whether to pay an API round-trip to confirm before redirecting; these are permanent citation links, so correctness may be worth the latency.

3. The referrer rule

Requested behaviour: a legacy URL should go to the new page normally, but stay on ww1 when the visitor is already browsing the legacy site (the legacy app is likely to emit absolute nemar.org links, which would otherwise eject people mid-session).

Referer: ww1.nemar.org   → https://ww1.nemar.org/dataexplorer/detail?dataset_id=ds007964
otherwise                → https://nemar.org/dataset/on007964

Two constraints on this:

  • Referer is unreliable — stripped by privacy modes, absent on typed/bookmarked navigation, absent on some cross-origin hops. So absent referer must default to the new site, since that is the citation case and the one that matters most.
  • A referrer-varying response cannot be edge-cached without Vary: Referer, which fragments the cache by an unbounded header. Use no-store on these redirects, consistent with the redirect policy from Cross-host 301s are browser-cacheable, pinning clients through a route reclassification #183.

4. DOI forwarders and the rest of the inventory

There are existing 301 forwarders for DOIs, and probably more legacy paths than the one above. This needs a real inventory before cutover, not a guess — the sources worth pulling from:

  • the legacy app's own route table
  • server logs / analytics for nemar.org/* paths with real traffic
  • DOI landing-page targets registered with DataCite/Zenodo (those must keep resolving or the DOIs break)
  • anything referenced in published NEMAR papers

getRetiredRedirect in src/lib/host.ts already handles /docs and /citation-dashboard and is the natural place to extend.

5. No banner on ww1, and no indexing either

Confirmed: the notice banner should not appear on ww1. It can't today — ww1 is a separate origin, not served by this build — so this is a "don't add it later" note.

More pressing: ww1 must be noindex, or the legacy site competes with the new one for the same content and splits ranking. That's the legacy origin's job, not this repo's, but it belongs on the cutover checklist. isNoindexHost in src/lib/host.ts governs only hosts this build serves.

6. Checklist

  • Inventory legacy URL patterns with real traffic
  • Decide transform-only vs. transform-plus-verify for ds → on
  • Implement legacy redirects with the referrer rule, no-store
  • Confirm every DOI landing target still resolves post-cutover
  • Flip MARKETING_BASE_URL + site, attach apex in Pages
  • 301 ww2.nemar.org → apex
  • noindex on ww1 (legacy origin change)
  • Update the notice currently pointing at ww1.nemar.org once it is actually live there

Activity

  1. neuromechanist commented on Jul 25, 2026

    @neuromechanist
    ContributorAuthor

    Resolved: the ds ⇄ on digit correspondence is a contract, not a coincidence. on007964 is ds007964, by design.

    That settles the open question in §2 — use the plain string transform, no API round-trip. /dataexplorer/detail?dataset_id=ds007964 → /dataset/on007964 is a pure rewrite, which keeps the redirect fast and cacheable and removes a failure mode. The fallback to /discover?search=<ds-id> is still worth keeping for a dataset that was never imported at all (a ds id with no on counterpart), which is a different case from a broken mapping.

    One gap worth closing separately

    The contract isn't enforced anywhere in code. importDatasetSchema in nemar-cli (backend/src/routes/admin/imports.ts) validates the two fields independently:

    dataset_id: z.string().regex(/^on\d{6}$/, "Import only supports 'on' prefix datasets (on######)"),
    source_id:  z.string().min(1).max(50),

    Nothing checks that their digits agree, so { dataset_id: "on999999", source_id: "ds000001" } is accepted today. It has never happened — 199/199 sampled rows are digit-preserving — but once the apex is doing permanent, citation-facing rewrites on the strength of this contract, a single violating import would silently route a cited URL to the wrong dataset. That is a worse failure than a 404, and an unnoticeable one.

    Cheap to close, upstream in nemar-cli:

    .refine((v) => v.dataset_id.slice(2) === v.source_id.slice(2), {
      message: "dataset_id and source_id must share the same six digits (on###### ⇄ ds######)",
    })

    plus a test asserting the invariant across the catalog. Happy to raise it there — it's a few lines and it turns a convention the redirect layer depends on into something the API actually guarantees.

  2. neuromechanist commented on Jul 25, 2026

    @neuromechanist
    ContributorAuthor

    Correction on §4 — the DOI concern was misplaced, and the real picture is better than I wrote.

    The historical DOIs were never NEMAR-minted and never resolved to nemar.org, so there is nothing to preserve there. The NEMAR-minted ones already resolve to the apex in the new URL format. Traced end to end:

    $ curl -sIL https://doi.org/10.82901/nemar.on007964
    302  ->  https://nemar.org/dataset/on007964      # DOI target: apex, new format
    301  ->  https://ww2.nemar.org/dataset/on007964  # legacy origin bridging to the new site
    200
    

    Every dataset in the sampled catalog carries one (10.82901/nemar.on######), and the DOI encodes the on id directly — the same contract the URL rewrite relies on.

    The cutover improves this rather than threatening it. The DOI target is already nemar.org/dataset/on######; once the apex is the new site, that resolves in one hop and the bridging 301 disappears on its own. Nothing to re-register, and no DataCite/Zenodo update needed.

    Two consequences worth recording:

    • ww2 does not need to live forever. No DOI references it — the bridge points to ww2, nothing points at it as a permanent target. So 301'ing ww2 → apex after cutover is safe; it only serves people who bookmarked the beta hostname.
    • The /dataset/* forwarder on the legacy origin is what makes DOIs work today, so it must not be removed before the apex switch, only after.

    Struck from the checklist: "Confirm every DOI landing target still resolves post-cutover." Replaced with: verify after cutover that https://doi.org/10.82901/nemar.on007964 reaches the dataset page in one hop.

    Also worth noting: the legacy origin is currently erroring

    $ curl -sI 'https://nemar.org/dataexplorer/detail?dataset_id=ds007964'
    HTTP/2 521
    server: cloudflare
    

    521 is Cloudflare's "web server is down" — the F5 origin isn't answering for that path right now, while /dataset/* (a Cloudflare-level redirect rule, not the origin) still works. Worth knowing before cutover planning assumes the legacy app is healthy: the legacy dataset-detail URLs cited in papers appear to be already broken, which makes the rewrite in §2 more urgent than a nicety, and means the ww1 migration is standing up something that isn't currently serving.

  3. neuromechanist commented on Jul 25, 2026

    @neuromechanist
    ContributorAuthor

    Blocker to fix before cutover: the temporary bridge is a permanent redirect

    The apex → ww2 forward is intended to be temporary, but it is implemented as a 301 with no Cache-Control:

    $ curl -sI https://nemar.org/dataset/on007964
    HTTP/2 301
    location: https://ww2.nemar.org/dataset/on007964
    server: cloudflare
    

    A bare 301 is heuristically cacheable, and browsers cache permanent redirects persistently. This is exactly the failure mode from #183 — except the consequence here is worse than staleness.

    At cutover this produces an infinite redirect loop. Walk it through for a visitor whose browser cached the current 301:

    1. Cached: nemar.org/dataset/X → ww2.nemar.org/dataset/X
    2. After cutover, the plan is ww2 → 301 → apex
    3. User opens nemar.org/dataset/X → browser follows its cached 301 → ww2/dataset/X → server 301s back to apex → browser follows the cached 301 again → …

    ERR_TOO_MANY_REDIRECTS, and no server-side change reaches it, because the poisoned entry is in the user's own cache. It hits DOI traffic specifically, since 10.82901/nemar.on###### resolves through exactly this path — so the affected population is people arriving from published citations.

    Two changes, in this order

    1. Now — switch the Cloudflare redirect rule from 301 to 302. Every day it stays a 301, more caches are poisoned. This is a rule setting, not code, and it costs nothing: the bridge is temporary by definition, so 302 is also the semantically correct status. Adding Cache-Control: no-store to the rule response is worth doing at the same time.

    2. At cutover — do not have ww2 redirect to apex immediately. Let ww2.nemar.org keep serving for a grace period (it is the same Pages project, so this is free) rather than 301'ing to apex. Then a still-poisoned cache lands on ww2 and gets a working page instead of a loop. Once enough time has passed for the old 301s to age out, switch ww2 → apex.

    Doing (2) alone is enough to prevent the loop even for caches already poisoned today, which is why it belongs in the cutover plan rather than being left to chance. Doing (1) as well shrinks the affected population from here on.

    Checklist additions

    • Change the apex → ww2 rule to 302 + no-store (do this now, independent of cutover)
    • At cutover, keep ww2 serving; defer the ww2 → apex redirect until cached 301s have aged out
    • After cutover, verify https://doi.org/10.82901/nemar.on007964 reaches the dataset page in one hop
  4. neuromechanist commented on Jul 25, 2026

    @neuromechanist
    ContributorAuthor

    Target shape for tomorrow

    Cutover is imminent, so here is the concrete end state and the one thing that must not be done.

    Good news: the code already handles the SEO half

    Base.astro derives canonical from MARKETING_BASE_URL, not from the request host:

    const siteOrigin = hostMode(reqHost) === "app" ? `https://${APP_HOST}` : MARKETING_BASE_URL;
    const canonicalUrl = new URL(Astro.url.pathname, siteOrigin).toString();

    MARKETING_HOSTS already contains nemar.org, www.nemar.org and ww2.nemar.org, so once the constant flips, every ww2 page canonicalises to the apex automatically. ww2 stays crawlable (isProductionHost → not noindex) but points search engines at the apex — which is exactly the shape that lets ww2 keep serving without competing for rankings. OG URLs and the sitemap follow the same constant.

    The change set

    Code (two constants, kept in lockstep per AGENTS.md):

    • MARKETING_BASE_URL in src/lib/host.ts → https://nemar.org
    • site in astro.config.mjs → https://nemar.org

    Infrastructure:

    • Attach nemar.org (and www) to the nemar-website Pages project
    • Point apex DNS at Pages
    • Remove the Cloudflare redirect rule nemar.org/dataset/* → ww2.nemar.org — while it exists the apex can never serve, it just bounces. This is the step most likely to be forgotten, because the rule lives outside the repo and currently looks like it's helping.

    The one thing not to do tomorrow

    Do not add a ww2.nemar.org → apex redirect. Leave ww2 serving.

    Browsers have been caching the current bare 301 from apex → ww2 (no Cache-Control, so cached persistently). If ww2 starts redirecting back to the apex, any visitor holding that cached entry enters an infinite loop that no server-side change can reach. Leaving ww2 serving means a poisoned cache lands on a working page instead. Retire ww2 later, once those entries have aged out.

    Switching the existing rule to 302 is still worth doing if it's free, but with cutover a day away it only prevents one more day of poisoning — the sequencing above is what actually protects the caches already out there.

    Expected end state

    Host Serves Canonical
    nemar.org new site (Pages) self
    www.nemar.org new site nemar.org
    ww2.nemar.org new site, kept alive nemar.org
    app.nemar.org authenticated surface self
    ww1.nemar.org legacy n/a — needs noindex

    DOIs resolve doi.org → nemar.org/dataset/on###### in one hop, with the bridge gone.

    Not blocking, but know the state

    The legacy /dataexplorer/detail?dataset_id=… rewrite (§2) will not be ready by tomorrow. That is survivable because those URLs are already returning 521 today — the F5 origin isn't answering them — so the cutover doesn't regress anything. It does mean cited legacy URLs stay broken until the rewrite ships, which is an argument for doing it soon after rather than eventually.

  5. neuromechanist commented on Jul 25, 2026

    @neuromechanist
    ContributorAuthor

    Refinement to §2 — on is not the only prefix, and the target is the DOI landing page

    Two corrections from checking the live catalog rather than assuming.

    Confirmed target semantics. Direct access to a legacy dataset URL should land on the new dataset page — which is precisely where the NEMAR DOI resolves:

    10.82901/nemar.on007964  →  nemar.org/dataset/on007964
    

    So the rewrite target and the DOI landing page are the same URL. That is a useful invariant: if the rewrite ever disagrees with the DOI resolution for a dataset, one of them is wrong.

    The catalog is on + nm, not just on. Sampled 200 rows: 199 on, 1 nm. And they behave differently:

    prefix origin source / source_id
    on###### OpenNeuro mirror openneuro / ds######
    nm###### NEMAR-native upload null / null

    nm rows have no source id at all, so they have no ds counterpart and need no mapping. More prefixes are expected, so the rewrite must not assume the ds → on shape is universal.

    Bare ds ids are also not addressable — GET /datasets/ds007964 returns 400, not 404, so /dataset/ds###### was never a valid destination. Good: it means there's no ambiguity about whether to rewrite or pass through.

    Revised rule

    ds###### → /dataset/on######      (contract; nemar-cli#1030 will enforce it)
    nm###### → /dataset/nm######      (identity — already the new format)
    on###### → /dataset/on######      (identity)
    anything else → /discover?search=<id>
    

    Plus the fallback that matters: a ds id that was never imported has no on counterpart, and rewriting it produces a 404 on a cited URL. Send those to /discover?search=ds###### so a reader still finds something. Whether to detect that by pre-checking the API or by handling the 404 downstream is the open decision.

    And the ww1 half

    Confirmed intent: ww1 must keep serving legacy pages intact — someone browsing the legacy site stays there. Only direct arrivals at a legacy dataset URL (a citation, a bookmark, a search result) are rewritten to the new page. That is what the referrer rule encodes, with absent-Referer defaulting to the new site because that is the citation case.

    Filed nemar-cli#1030 to enforce the on ⇄ ds correspondence at the import endpoint, scoped per-source so nm and future prefixes aren't swept into a rule that doesn't apply to them.

  6. neuromechanist commented on Jul 25, 2026

    @neuromechanist
    ContributorAuthor

    §2 is mostly already built — and it's better than what I proposed

    /dataset/ds007763 already 301s to /dataset/on007763 in production. Verified:

    $ curl -sI https://ww2.nemar.org/dataset/ds007763
    301  ->  https://ww2.nemar.org/dataset/on007763
    

    src/pages/dataset/[id].astro detects ^ds\d{6}$ and resolves it — and crucially it does so with a real lookup, not the string transform I was recommending:

    if (/^ds\d{6}$/.test(id)) {
      const canonical = await resolveCanonical(id).catch(() => null);
      if (canonical) return Astro.redirect(`/dataset/${canonical}${url.search}`, 301);
    }

    resolveCanonical hits a dedicated backend endpoint, GET /datasets/resolve/<sourceId> → { found, dataset_id }. That is strictly better than a prefix swap: it handles a ds that was never imported by returning null and falling through, instead of confidently redirecting to an on id that doesn't exist. It also means the rewrite doesn't depend on the digit contract holding — nemar-cli#1030 is now belt-and-braces rather than load-bearing.

    So the remaining work is only the legacy path shape, not the id mapping:

    /dataexplorer/detail?dataset_id=ds007964  →  /dataset/ds007964  →  (existing 301)  →  /dataset/on007964
    

    Worth deciding whether the legacy handler calls resolveCanonical itself to collapse two hops into one, or just rewrites the path and lets the existing redirect do its job. The second is less code and one implementation of the resolution rule; the first is one fewer round trip on a citation link.

    One thing to fix on that path first

    resolveCanonical is the recurring undefaulted-AbortSignal bug (website#173), and it sits on the exact path that is about to carry citation traffic:

    const res = await fetch(url, { signal: init.signal, ... });   // undefined when the caller passes nothing

    [id].astro calls it as resolveCanonical(id).catch(() => null) — no init, so no deadline. A try/catch covers a request that fails; it does not cover one that opens and never responds. That promise never settles, and this runs during SSR, so a hung /datasets/resolve/ stalls the render of every ds* dataset page — which after cutover means every legacy citation URL.

    Worth closing before the legacy rewrite multiplies traffic onto it.

  7. neuromechanist commented on Jul 29, 2026

    @neuromechanist
    ContributorAuthor

    Done. nemar.org now serves the redesigned site; the legacy HUBzero site lives at ww1.nemar.org.

    SDSC's side, verified before starting

    Both requested changes confirmed against the origin IP with only the Host header varying:

    Host: ww1.nemar.org         -> 200   (was 302; ServerAlias in place)
    Host: nemar.org             -> 200
    Host: totallyfake.nemar.org -> 302   (catch-all canonical redirect still intact)
    

    And the base URL now follows the request host: <base href="https://ww1.nemar.org/dataexplorer" />. Confirmed end-to-end through DNS as well, not just against the origin IP.

    What changed

    before after
    nemar.org DNS A -> 132.249.225.118 (legacy F5), proxied CNAME -> nemar-website.pages.dev, proxied
    Pages custom domains app, ww2 app, ww2, nemar.org, www.nemar.org
    Dynamic redirect rule nemar.org/dataset/* -> ww2 (301) deleted
    ww2.nemar.org serving still serving, deliberately

    Ordering was deliberate: the apex was attached to Pages before the redirect rule was removed, so DOI resolution never broke. DOIs point at nemar.org/dataset/<id>, and deleting the rule while the apex was still legacy would have dropped them.

    The iCloud MX/SPF/TXT records on the apex were left untouched.

    Constants were already flipped, ahead of schedule

    feat/apex-cutover-constants turned out to have a zero diff against main: MARKETING_BASE_URL and site were already https://nemar.org, having landed via #193 (ab8e372) rather than through the gated branch. That is exactly the failure this issue warned about — "merging it before DNS moves breaks app.nemar.org, which would then redirect marketing routes to a legacy origin" — and it had been live for roughly four days. Signed-in users clicking Discover were 301'd onto the legacy HUBzero site. The cutover resolves it; the branch can be deleted.

    Verified after cutover

    nemar.org/                     200  <title>NEMAR</title>, zero legacy markers
    nemar.org/discover|/about|/signup   200
    www.nemar.org/                 200
    nemar.org/dataset/on007964     200  direct, no redirect hop, JSON-LD present
    nemar.org/dataset/ds002718     301 -> /dataset/on002718   (canonical resolve intact)
    nemar.org/dataexplorer/detail?dataset_id=ds002718  301 -> /dataset/ds002718
    nemar.org/dataexplorer         301 -> /discover
    nemar.org/{resources,tools,members}  302 -> ww1.nemar.org  (targets serve 200)
    ww1.nemar.org/dataexplorer     200  legacy, ww1-scoped <base>
    ww2.nemar.org/                 200  still serving
    app.nemar.org/login            200
    canonical on apex              https://nemar.org/...
    canonical on ww2               https://nemar.org/...   (defers, won't compete)
    robots.txt on apex             Allow: /
    

    ww2 stays up

    Not an oversight. The old apex -> ww2 bridge was a bare 301 with no Cache-Control, so browsers cached it persistently. If ww2 were pointed back at the apex, those clients would loop (apex -> ww2 -> apex -> ...) and no server-side change could reach them. Leaving ww2 serving means a poisoned cache lands on a working page. Retire it only once those entries have aged out. Canonical tags already point at the apex, so it won't compete for rankings in the meantime.

    Follow-up

    #210 — a signed-in user following a marketing link still lands on the anonymous host and appears signed out. Distinct from this issue (that was the legacy-origin ejection); this is the architectural half that remains now that the destination is correct.

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