Open MercatoDocsSearch docsAPI reference

Framework

Cross-Site Login Protection

A sign-in request changes which account a browser will use. The login origin policy checks where that request came from. Use this reference when your login interface and application live on different origins and you need to allow the intended pairing.

The staff and customer portal sign-in flows check the browser request origin before issuing session cookies. This protects sessions against unwanted cross-site sign-in.

The routes that issue a session from a request body therefore reject cross-site browser requests with 403 { ok: false, error } before they read the body:

RouteSession cookies
POST /api/auth/loginauth_token, session_token
POST /api/auth/session/refreshauth_token
POST /api/customer_accounts/logincustomer_auth_token, customer_session_token
POST /api/customer_accounts/magic-link/verifycustomer_auth_token, customer_session_token
POST /api/customer_accounts/invitations/acceptcustomer_auth_token, customer_session_token

How the application checks browser requests

The sign-in routes reject cross-site browser requests and check the configured origin when needed. The first-party sign-in pages use same-origin requests. Keep trusted origins explicit and review rejection logs when a legitimate hostname stops working.

Configuration

Configuration only matters for requests that reach step 3: browsers that send no Fetch Metadata, and same-site requests from a sibling subdomain. For those, make sure the origin is recognised:

APP_URL=https://admin.example.com
APP_ALLOWED_ORIGINS=https://ops.example.com

Alternatively, let the reverse proxy forward X-Forwarded-Host (and X-Forwarded-Proto).

A sign-in form on a sibling subdomain (for example www.example.com posting to app.example.com) works once its origin is listed in APP_ALLOWED_ORIGINS. APP_ALLOWED_ORIGINS cannot re-enable a sign-in form hosted on a different site. The browser marks that request Sec-Fetch-Site: cross-site, which is always rejected. Sign in on the application's own origin, or call the API from a server.

Previous: Scheduler Module · Next: Rate Limiting