bruno
bruno copied to clipboard
[Bug] process.env is empty in all script environments
I have a .env
file in my collection root. The contents are:
MY_SECRET=123456
I can use this in request headers like so:
But when I try to use it in any of the scripting environments, the value is always null
:
For reference, this is my bru
file:
meta {
name: Todo1
type: http
seq: 3
}
get {
url: https://jsonplaceholder.typicode.com/todos/1
body: none
auth: none
}
headers {
my_header: {{process.env.MY_SECRET}}
}
script:pre-request {
console.log(process.env.MY_SECRET)
}
script:post-response {
console.log(process.env.MY_SECRET)
}
tests {
console.log(process.env.MY_SECRET)
}
Workaround: You can define an environment variable like this:
And then use it via the familiar bru.getEnvVar("the_workaround")
syntax.