Repository navigation
Description
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_URLinsrc/lib/host.ts→https://nemar.orgsiteinastro.config.mjs→https://nemar.org(AGENTS.md says keep these in lockstep)- Attach the apex to the
nemar-websitePages project (currently onlyww2andappare attached) - Add
ww1.nemar.orgtoMARKETING_HOSTS? No — see §5. ww1 is a separate origin, not this build. - Decide what
ww2.nemar.orgdoes 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:
Refereris 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. Useno-storeon 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 -
noindexon ww1 (legacy origin change) - Update the notice currently pointing at
ww1.nemar.orgonce it is actually live there
Activity
neuromechanist commentedon Jul 25, 2026
Resolved: the
ds⇄ondigit correspondence is a contract, not a coincidence.on007964isds007964, by design.That settles the open question in §2 — use the plain string transform, no API round-trip.
/dataexplorer/detail?dataset_id=ds007964→/dataset/on007964is 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 (adsid with nooncounterpart), which is a different case from a broken mapping.One gap worth closing separately
The contract isn't enforced anywhere in code.
importDatasetSchemain nemar-cli (backend/src/routes/admin/imports.ts) validates the two fields independently: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:
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.
neuromechanist commentedon Jul 25, 2026
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:
Every dataset in the sampled catalog carries one (
10.82901/nemar.on######), and the DOI encodes theonid 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→ apex after cutover is safe; it only serves people who bookmarked the beta hostname./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.on007964reaches the dataset page in one hop.Also worth noting: the legacy origin is currently erroring
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.neuromechanist commentedon Jul 25, 2026
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
301with noCache-Control:A bare
301is 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:
nemar.org/dataset/X→ww2.nemar.org/dataset/Xww2→301→ apexnemar.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, since10.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
302is also the semantically correct status. AddingCache-Control: no-storeto the rule response is worth doing at the same time.2. At cutover — do not have ww2 redirect to apex immediately. Let
ww2.nemar.orgkeep 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
302+no-store(do this now, independent of cutover)https://doi.org/10.82901/nemar.on007964reaches the dataset page in one hopneuromechanist commentedon Jul 25, 2026
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.astroderives canonical fromMARKETING_BASE_URL, not from the request host:MARKETING_HOSTSalready containsnemar.org,www.nemar.organdww2.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_URLinsrc/lib/host.ts→https://nemar.orgsiteinastro.config.mjs→https://nemar.orgInfrastructure:
nemar.org(andwww) to thenemar-websitePages projectnemar.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
301from apex → ww2 (noCache-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
302is 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
nemar.orgwww.nemar.orgnemar.orgww2.nemar.orgnemar.orgapp.nemar.orgww1.nemar.orgnoindexDOIs 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.neuromechanist commentedon Jul 25, 2026
Refinement to §2 —
onis not the only prefix, and the target is the DOI landing pageTwo 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:
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 juston. Sampled 200 rows: 199on, 1nm. And they behave differently:source/source_idon######openneuro/ds######nm######nmrows have no source id at all, so they have nodscounterpart and need no mapping. More prefixes are expected, so the rewrite must not assume theds→onshape is universal.Bare
dsids are also not addressable —GET /datasets/ds007964returns400, not404, so/dataset/ds######was never a valid destination. Good: it means there's no ambiguity about whether to rewrite or pass through.Revised rule
Plus the fallback that matters: a
dsid that was never imported has nooncounterpart, 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-
Refererdefaulting to the new site because that is the citation case.Filed nemar-cli#1030 to enforce the
on⇄dscorrespondence at the import endpoint, scoped per-source sonmand future prefixes aren't swept into a rule that doesn't apply to them.neuromechanist commentedon Jul 25, 2026
§2 is mostly already built — and it's better than what I proposed
/dataset/ds007763already 301s to/dataset/on007763in production. Verified:src/pages/dataset/[id].astrodetects^ds\d{6}$and resolves it — and crucially it does so with a real lookup, not the string transform I was recommending:resolveCanonicalhits a dedicated backend endpoint,GET /datasets/resolve/<sourceId>→{ found, dataset_id }. That is strictly better than a prefix swap: it handles adsthat was never imported by returning null and falling through, instead of confidently redirecting to anonid 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:
Worth deciding whether the legacy handler calls
resolveCanonicalitself 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
resolveCanonicalis the recurring undefaulted-AbortSignalbug (website#173), and it sits on the exact path that is about to carry citation traffic:[id].astrocalls it asresolveCanonical(id).catch(() => null)— no init, so no deadline. Atry/catchcovers 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 everyds*dataset page — which after cutover means every legacy citation URL.Worth closing before the legacy rewrite multiplies traffic onto it.
neuromechanist commentedon Jul 29, 2026
Done.
nemar.orgnow serves the redesigned site; the legacy HUBzero site lives atww1.nemar.org.SDSC's side, verified before starting
Both requested changes confirmed against the origin IP with only the
Hostheader varying: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
nemar.orgDNSnemar.org/dataset/*-> ww2 (301)ww2.nemar.orgOrdering 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-constantsturned out to have a zero diff againstmain:MARKETING_BASE_URLandsitewere alreadyhttps://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
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.