v1.1.0
This release opens visitor contexts to your other first-party websites. A new public endpoint lets your other sites resolve the same anonymous context as the application.
Highlights
- New public
POST /api/contextendpoint returning the visitor's context ID. - New
I_S_CONTEXT_ALLOWED_ORIGINSenvironment variable listing the other first-party origins allowed to use it. - Browser requests coming from an origin that is not allowed are rejected.
Added
- Added
App\Http\Controllers\Api\ContextController, registered asPOST /api/context. It runs the APISetContextmiddleware, is rate-limited to 60 requests per minute, and returns the resolved context as{"contextId": ...}with ano-storeCache-Controlheader. A request that resolves no context returns a422. - Added the
context_allowed_originsoption toconfig/inertia-start.php, built from the newI_S_CONTEXT_ALLOWED_ORIGINSenvironment variable. The value is a comma-separated list of origins; entries are trimmed, empty ones are dropped, and duplicates are removed. The application's own origin is always accepted and does not need to be listed. - Added
I_S_CONTEXT_ALLOWED_ORIGINSto.env.example. - Added feature coverage for the new endpoint in
tests/Feature/GuestContextTest.php: resolving a context from an allowed origin, the browser preflight request, the missing fingerprint and unknown origin rejections, and an existing fingerprint being reused instead of creating a second context.
Changed
App\Http\Middleware\Api\SetContextnow checks theOriginheader of requests carrying anX-Guestfingerprint. A request whose origin is neither the application's own origin nor one ofcontext_allowed_originsis rejected with a403. Requests sent without anOriginheader, such as server-to-server calls, are unaffected.- The middleware now ignores an empty
X-Guestheader. Previously the header only had to be present, so an empty value produced a context keyed on the client IP address alone.
Upgrade Guide
-
No migration and no configuration change are required. Without
I_S_CONTEXT_ALLOWED_ORIGINS, the new endpoint only answers browser requests coming from the application's own origin. -
To share contexts with another first-party website, add its origin to
I_S_CONTEXT_ALLOWED_ORIGINSin your.envfile:I_S_CONTEXT_ALLOWED_ORIGINS=https://www.example.com,https://docs.example.comOrigins are matched exactly: scheme and host, plus the port when one is used, with no path and no trailing slash.
-
That website then sends its Thumbmark fingerprint to
POST /api/contextin theX-Guestheader and reuses the returned context ID, for instance to identify its Umami session withcontext:{contextId}. Keep@thumbmarkjs/thumbmarkjsat the same version on both sides, since two versions can produce two different fingerprints for the same browser. -
If you do not want to expose the endpoint at all, remove the
contextroute fromroutes/api.php.