Conversation
On localhost the IMS token is always minted against IMS stage (da-nx env resolves localhost to 'dev' -> stage). da-live's own env resolver defaults localhost to prod, so a stage token hits prod admin.da.live -> 401 -> /not-found. Add a failing test asserting localhost defaults to stage-admin.
On localhost the IMS token is always minted against IMS stage (da-nx resolves a localhost host to env 'dev', which targets stage for both the token and nx2's DA_ADMIN). da-live's own env resolver defaulted localhost to prod, so the stage token hit prod admin.da.live, got a 401, and da-nx's daFetch redirected the browser to /not-found. Align da-live with da-nx by defaulting the da-admin backend to stage on localhost (content/collab/preview keep their existing prod default and the documented ?da-collab=stage override). An explicit ?da-admin= param still wins, and non-local hosts are unaffected. Update tests that derived URLs from the localhost DA_ORIGIN to build the expected value from DA_ORIGIN instead of hardcoding the prod host.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Opening a site in the local dev server (e.g.
http://localhost:3020/#/benpeter/hlx6-test) redirects to/not-found, even though the same site loads fine on prod da.live.Root cause is an environment mismatch between da-live and da-nx for the
localhosthost:localhost, the IMS token is always minted against IMS stage (da-nx'senvresolver maps localhost ->dev, anddev-> thestg1IMS environment). This is not overridable per request.blocks/shared/constants.jsgetDaEnv) had no concept of localhost and defaulted every backend to prod. SoDA_ORIGINpointed atadmin.da.live(prod).daFetch(blocks/shared/utils.js) redirects to/not-foundon a 401 against a DA origin after one refresh attempt — hence the redirect.da-nx (nx2) already defaults its
DA_ADMINto stage on localhost, so the two halves of the app disagreed about which admin to talk to.Fix
Align da-live's admin default with da-nx: on localhost,
DA_ORIGIN/getDaAdmin()now default to stage-admin.da.live, matching the stage IMS token. A stage token now reaches stage admin, which returns 403/404 (not 401) for a not-yet-authorized config read — and da-live'sdaFetchreturns on 403 rather than redirecting, so the browser falls through to the default editor instead of/not-found.Scope is deliberately narrow — admin only. Content, collab, and preview origins keep their existing prod default (with the existing
?da-content=stage/?da-collab=stagemanual overrides unchanged). Explicit overrides (?da-admin=prod,?da-admin=reset) still win everywhere.getDaEnvgains an optionallocalDefaultparameter (defaults toprod, so all other callers are unchanged) and now keys offurl.hostname.includes("local"), matching da-nx's own localhost detection.Verification
test/unit/blocks/shared/constants.test.jsassert localhost -> stage-admin, non-local -> prod, and explicit-override precedence.constants.jsresolvesDA_ORIGIN = https://stage-admin.da.liveon localhost,https://admin.da.livewith?da-admin=prod, andhttps://admin.da.liveon prod da.live; content/collab origins unchanged in all cases.Follow-up
da-live maintaining its own env resolver in parallel with da-nx's is the underlying source of this drift. A follow-up could consolidate da-live onto nx2's
DA_ADMIN/ env resolution so the two can never disagree again.