Call the tenant host directly
If you cannot route /edgekit/ on your own domain, your pages can send EdgeKit requests to the tenant host itself,
such as https://<tenant>.edgekit.ai/edgekit/v1/decide. The browser client does this when you set its baseUrl
(BrowserClientOptions).
Keep the /edgekit/ prefix on the tenant host too: it answers every /edgekit/ path the same way your own domain
does. The browser credential (the site header and the origin check) is on /edgekit/v1/ paths on either host. On the
tenant host, /v1/decide takes an API key and refuses a browser with 401.
What you lose
Section titled “What you lose”- One session for both hosts, unless your organization’s cookie domain covers both. By default the sign-in cookie
is host-only: it stays on the host the user signed in through. When your pages sign in through the tenant host, and
the tenant host shares your site’s domain, such as
edgekit.example.comforwww.example.com, later requests to the tenant host keep the session. A session started on your own host, through the/edgekit/path, is not sent to the tenant host. With a cookie domain such asexample.com, one session serves both hosts. A tenant host on another domain never gets the cookie. Without a session, decide still answers200, as for an anonymous device, with no error, and requests that need a signed-in user answer401unauthorized. - Same-origin requests: every request is cross-origin, so the browser sends a CORS preflight first. Add the tenant
host to your Content Security Policy’s
connect-src. - First-party analytics: to send events to the tenant host, set the tracker’s
collectorOriginto the tenant host (EdgeKitTrackerOptions). The tracker posts to/edgekit/a/tthere, as on your own domain. Events then go to a host other than your page’s own. - Outcome previews on journey redirects: the
edgekit_previewcookie stays on your site’s host, so a journey redirect through the tenant host is answered as deployed. Decides from the browser client still carry the preview, as a header. See Preview an outcome on your site. - Experiences: the browser client loads an experience’s module from
/edgekit/x/on your page’s own domain, whateverbaseUrlsays. With no/edgekit/route there, the module does not load, no experience is drawn, and the tracker getsexperience_errorwithload_failed. See Experiences.
How cross-origin requests are checked
Section titled “How cross-origin requests are checked”- The preflight: the tenant host answers a preflight from any origin, for the methods the route serves. It
allows the request headers
content-type,x-edgekit-site-idandtraceparent, and decide also allowsx-edgekit-preview. A browser may reuse the answer for 10 minutes. The preflight grants nothing: it cannot see which site is asked for. - The request: the real request names its site in
x-edgekit-site-id, and itsOriginis checked against that site’s allowed origins. An allowed origin getsAccess-Control-Allow-Originwith its own value, andAccess-Control-Allow-Credentials: true. - A refusal answers
403forbiddenwith no CORS headers, so the browser reports a CORS error and your code cannot read the body.
The browser cannot send an Authorization header to the tenant host: the preflight does not allow it. API keys
belong on servers.
/edgekit/v1/id/config and /edgekit/v1/id/traits skip the origin check: they carry no credential and answer
Access-Control-Allow-Origin: *.