Password authentication for certain pages of the website


I have a NextJs application and I am hoping to add password authentication for pages with the query ?preview=true present. I would like to authenticate pages that have this query since they contain draft data usually and is just for content creators to see what something looks like.

I have done this in the past for full pages like for=‘/preview’ but not for query parameters. Is that even possible? I tried adding something like this for = “/.[?&]preview=true.” and then tested on a deployment preview link: Our Train Vacation Brochures, Via Rail & Rocky Mountaineer, and it did not ask for any authentication.

How can I fix this or add this authentication? Any help will be appreciated!

Perhaps this support guide helps?

Caveat: I do not use access control / identity on any of my sites and I am just another user.

1 Like

You might also consider adding authentication into Next.js for specific routes. See

1 Like

Thanks a lot you two! You’ve pushed me in the right direction :slight_smile: