-
Notifications
You must be signed in to change notification settings - Fork 0
Troubleshooting
The frontend is a BFF: it makes server-side calls to the deployed Sec4 Pay PSP (token exchange,
JWKS, and the wallet API). That PSP host sits behind MongoDB's corporate SSO gate
(Istio/Envoy → login.corp.mongodb.com).
- Your browser passes the gate, it carries a corp session.
- The Node server (your local
npm run dev) does not. So every server-side request gets302'd tologin.corpand fails (you'll see the token exchange or JWKS fetch error out).
To develop locally against the deployed PSP, the server needs to present the same corp session your
browser has. That's what PSP_DEV_COOKIE is for.
The cookie is read only when NODE_ENV !== 'production' (see frontend/src/lib/auth/env.js,
ENV.pspDevCookie). When the app is deployed on MongoDB's own infra, server-to-server traffic isn't
gated, so the cookie is never read and the whole mechanism is inert, nothing to configure, nothing to
remove. It exists purely so a laptop can reach the gated staging host.
-
In your browser (logged into corp), open the PSP discovery URL directly, it should return JSON:
<PSP_BASE_URL>/.well-known/openid-configuration(
PSP_BASE_URLis the backend host infrontend/.env.local.) -
Open DevTools → Network → reload the tab, click the
openid-configurationrequest, go to Headers → Request Headers, and copy the entirecookie:value. Theauth_user/auth_claim_*/auth_tokencookies are the corp session; copying the whole header is fine. -
Add it to
frontend/.env.local, in double quotes (the value contains;and spaces):PSP_DEV_COOKIE="…paste the whole cookie here…" -
Restart the dev server (
.env.localis only read at startup):cd frontend && npm run dev
Log in: the server now attaches that cookie to every PSP request and passes the gate like your browser does.
-
It expires (a few hours, it's a live session token). When auth starts failing again with a gate
redirect (
token exchange failed: 401, orExpected 200 OK from the JWKS response), re-copy the cookie and replace the value. -
Never commit it.
.env.localis gitignored; the value is your personal corp session. - It's a stopgap. If the gate is ever opened for server-to-server to the PSP host, just delete
PSP_DEV_COOKIEfrom.env.localand everything works without it.
ENV.pspDevCookie() is attached as a Cookie: header (only when non-empty) on every server→PSP call:
-
frontend/src/lib/auth/oauth.js: token exchange, refresh, revoke, userinfo, CIBA, and the JWKS fetch (routed through the same helper via jose'scustomFetch). -
frontend/src/lib/psp/PspClient.js: the wallet API reads/writes. -
frontend/src/lib/auth/actions.js: the passwordless/CIBA relays.