How can I block the default Pages domain while allowing access to my custom domain?

What is the name of the domain?

app.aws-learn.click

What is the issue you’re encountering

I’m trying to use Access Applications to secure my Pages internal domain(s) while allowing my custom domain to remain public. It’s not working.

What steps have you taken to resolve the issue?

I’ve tried everything I can think of.

What are the steps to reproduce the issue?

My Page’s default domain is: prod-web-app-c96.pages.dev

When I build either for production or preview, there’s a random subdomain that’s assigned, ex: 0e20227d.prod-web-app-c96.pages.dev

I would like to make all of these domains private so they require permission to view. Both the ones with a subdomain *.prod-web-app-c96.pages.dev and the root domain prod-web-app-c96.pages.dev

However, I also have a custom domain assigned to my Pages app: app.aws-learn.click

This domain is mapped to the root domain that Pages provides: prod-web-app-c96.pages.dev

The problem is that when I block that root domain, it also blocks my custom domain.

Please see the attached screenshot to see how I’ve set things up.

My question is: Can I indeed block prod-web-app-c96.pages.dev while allowing my custom domain to remain public, even when my custom domain is pointing to prod-web-app-c96.pages.dev?

If not, how do I prevent the public (and indexing robots) from accessing my Page on both domains?

Screenshot of the error

Seems you’ve found a working solution already: block the preview subdomains, redirect the production subdomain to your custom domain.

Good luck!