Cloudflare Access on Pages conflicts with custom domains

When you visit a site that points to <site>.pages.dev via CNAME, and <site>.pages.dev (not *.<site>.pages.dev) is protected by Cloudflare Access, an error occurs that the page /cdn-cgi/access/authorized?nonce=...&state=... is not found.

Expected behavior:

  1. The site will request access rights by redirecting to <team>.cloudflareaccess.com.
  2. After confirming access rights, the user should be redirected to the page original.website/cdn-cgi/access/authorized, and then be redirected to the original page and it should load as usual.

Actual behavior:

  1. The site requests access rights by redirecting to <team>.cloudflareaccess.com
  2. After confirming access rights, the user is redirected to the original website, to the page /cdn-cgi/access/authorized?nonce=...&state=...
  3. The server responds with a 404 not found error.

How to reproduce:

  1. Create a website on Cloudflare Pages.
  2. Set custom domain in the website settings on Pages.
  3. In the website settings on Pages, create an access policy.
  4. Go to one.dash.cloudflare.com use the appropriate button and remove * from the subdomain settings for this access application. The application should be on <site>.pages.dev, not on *.<site>.pages.dev.
  5. If you go to <site>.pages.dev and confirm the access rights, everything will work fine. But if you refer to the domain that you set in step 2, you will get a 404 not found error.

Yeah you need Access to also be on the custom domain:

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.