You could probably use this plugin: netlify-plugin-inline-functions-env - npm and access the context using process.env.CONTEXT and differentiate branch-deploy and production accordingly.
In the end, I realized that this is not a Netlify but Cypress problem. The Netlify build script deployed the web, but the Cypress was then running tests on the feature branch. Since I was unable to force baseUrl config for Cypress, I used the following workaround:
/* In _redirects file */
# Forces cypress to run postBuild tests against custom domain, to prevent CORS error
https://master--appname.netlify.app/* https://customdomain.tld/:splat 301!