How Do I set up here basic auth for staging only environment, Also If its worth mentioning I got my staging and website on customdomain example.com so its staging.example.com and I want to password protect only this deployments
I already Upgraded to Team Plan, So I have this feature, just doesn’t know how to configure it only for one env (staging) with subdomain connected to it. Sure I can set up password from UI on whole site, but that’s not what I want, I only want my staging to be password protected
Hi @Lepryko, headers in the netlify.toml are global so they can’t be scoped to specific builds. However, the context is available as a build environment variable as is the BRANCH. This means you can create a _headers file or rename it during your build process. The simplest way is just doing a check to see if BRANCH is equal to staging and if so, rename your prepared headers.txt file to _headers . This can be done in whatever language you’re comfortable in, or just do it in bash. You can see the structure of the _headers file and basic auth in our docs
@Lepryko Can you share the contents of the headers.txt file? Can you also give me a link to the deploy where you have this up? Lastly, where did you get that CONTEXT name? is staging a branch? If so then you’re checking the wrong en var since the only deploy context we have are production, branch-deploy, deploy-preview. That’s in our docs: