Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to get variables pulling from .env located in http directory #1343

Open
NigelGreenway opened this issue Jan 10, 2025 · 2 comments
Open

Comments

@NigelGreenway
Copy link

I was looking at this feature request, and my understanding is that the following should work:

# .env
DOMAIN_URL=localhost
# setttings.json
{
    "rest-client.environmentVariables": {
        "local": {
            "DOMAIN_URL": "{{$dotenv DOMAIN_URL}}"
        }
    }
}
# endpoint.http
POST https://{{ DOMAIN_URL }}/some/endpoint HTTP/1.1

However, it does not seem to replace DOMAIN_URL with the value from the .env file.

Am I doing something wrong, or misunderstanding the functionality?

@domoran
Copy link

domoran commented Jan 11, 2025

You don't need anything in your settings.json

Just put the .env file in the same directly as the http file (not sure if it can also be in a parent directory or at project root level, could be worth trying out). and directly put in your request:

# .env
DOMAIN_URL=localhost

# endpoint.http
POST https://{{$dotenv DOMAIN_URL}}/some/endpoint HTTP/1.1

@NigelGreenway
Copy link
Author

Cheers @domoran. The issue here for me is if that's the case, then we can't share the .http file between the team as it's a mix of editors and this is VS Code specific 😞

I'm a vim user that is researching a way to share these via our code repos and across a team of 50+ engineers, so it looks like this plugin won't work then.

Using the setting config would have been the best solution for us.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants