vscode-restclient icon indicating copy to clipboard operation
vscode-restclient copied to clipboard

settings.json not parsing / evaluating dotenv values

Open asos-gurpreetsingh opened this issue 3 years ago • 2 comments

  • REST Client Version: latest
  • VSCode Version: latest
  • OS Version: windows 10

Steps to Reproduce:

  1. create settings json file with an environment section
  2. create env file with a value in it eg SECRET=this is a secret
  3. create a key in your settings json environment e.g. "someSecretFromEnv":"{{$dotenv SECRET}}"
  4. refer your "someSecretFromEnv variable in your request file

this only bring out un parsed value i.e. {{someSecretFromEnv}} becomes {{$dotenv SECRET}} but it should be evaluated to "this is a secret"

asos-gurpreetsingh avatar Apr 19 '21 11:04 asos-gurpreetsingh

It looks like from the docs https://github.com/Huachao/vscode-restclient#system-variables, scrolling down to the section under processEnv:

in your settings.json file, you only reference the env variable name, ie "someSecretFromEnv":"SECRET" then in your request file, you can use either {{$dotenv SECRET}} or {{$dotenv %someSecretFromEnv}}

Stetzon avatar Apr 21 '21 20:04 Stetzon

Referencing dotenv variables from settings.json would be very useful for setting default headers. Or is there another recommended way of setting default headers without having secrets directly in settings.json?

chrisvfritz avatar Aug 10 '23 13:08 chrisvfritz