Sink can optionally use Cloudflare Access as an alternative to the existing site token. When Access is not configured, authentication behaves exactly as before.
With Access configured, an API request is accepted when either condition is true:
- The request has a valid
NUXT_SITE_TOKENbearer token. - The request has a valid Cloudflare Access application JWT.
Sink verifies the Access JWT signature, issuer, audience, and expiration against your team's public keys. The presence of an Access header or cookie alone is never trusted.
This setup protects the dashboard while keeping public short links and SiteToken API clients unchanged.
- Create a Cloudflare Access self-hosted application for your Sink hostname.
- Configure its application path to cover both
/dashboardand its child routes. - Do not protect
/apiwith Access. Sink authenticates API requests itself using SiteToken or the signed Access application cookie. - In the Access application's advanced cookie settings:
- Keep Cookie Path disabled so the dashboard cookie is also sent to
/api. - Set SameSite to
LaxorStrictwhen your deployment does not require cross-site requests.
- Keep Cookie Path disabled so the dashboard cookie is also sent to
- Add the following Sink environment variables and redeploy:
NUXT_CF_ACCESS_TEAM_DOMAIN=https://your-team.cloudflareaccess.com
NUXT_CF_ACCESS_AUD=your-application-aud-tagBoth variables are required. The team domain should not have a path. The AUD tag is available in the Access application's additional settings.
Short-link paths, static assets, and API documentation remain public at the Cloudflare Access layer. API operations still require Sink authentication. Protect /_docs separately if the API schema should not be public.
In compatibility-first mode, /api is not evaluated by the Cloudflare Access proxy on every request. Sink validates the signed application JWT locally. As a result, an Access session revoked by an administrator may remain usable until its JWT expires. Use an appropriately short Access policy or application session duration.
Access uses a browser cookie, so Sink rejects cross-site browser requests authenticated through Access and verifies the Origin header for state-changing methods. SiteToken requests are unchanged. Non-browser clients should continue to use NUXT_SITE_TOKEN.
Do not expose an alternative deployment hostname with a weak SiteToken. Cloudflare Access on the dashboard does not protect other hostnames that route to the same Worker or Pages project.
When the dashboard is authenticated through Access, Sink redirects logout to /cdn-cgi/access/logout. Cloudflare revokes the Access session across applications and clears the application cookie.
For stronger edge enforcement, you can protect both /dashboard and /api with Access. In this mode, Cloudflare blocks requests before they reach Sink, so a SiteToken-only API client cannot use the protected hostname. Such clients must also use an Access service token or a separate API hostname.