netlify-plugin-contextual-env icon indicating copy to clipboard operation
netlify-plugin-contextual-env copied to clipboard

Different env var value for different deploy previews

Open JuanFdS opened this issue 5 years ago • 0 comments

Hi!, I'm just starting to use netlify and found your plugin while trying to setup different env vars for different environments, great work btw :clap:

One thing I wanted to do is having an env var, which we are using to set the backend url, that would be used only by one deploy preview, so then I could point different deploy previews to different backends (because the backend is deployed from a pull request too).

What I got from reading this plugin's code and trying out some things is that the DEPLOY_PREVIEW prefix sets the env var for all deploy previews, right?

I thought that using the branch prefix would make it possible and then ran into the problem that the BRANCH env var on deploy previews is a reference to the PR, not to the branch itself, so in my case it looks something like pull/2/head and / isn't an allowed character in netlify's UI to set nev vars.

Is there any other way I'm missing? (without using branch deploys instead of deploy previews)

I guess one way to support this would be to have the name of the branch transformed to replace / by _ the same way -s are being replaced before replacing the env vars. What do you think?

JuanFdS avatar Aug 12 '20 20:08 JuanFdS