mirror of
https://github.com/hoppscotch/hoppscotch.git
synced 2026-04-26 01:06:00 +03:00
[GH-ISSUE #1639] The Build Not accepting the custom Environment Variables but building on defaults #516
Labels
No labels
CodeDay
a11y
browser limited
bug
bug fix
cli
core
critical
design
desktop
discussion
docker
documentation
duplicate
enterprise
feature
feature
fosshack
future
good first issue
hacktoberfest
help wanted
i18n
invalid
major
minor
need information
need testing
not applicable to hoppscotch
not reproducible
pull-request
question
refactor
resolved
sandbox
self-host
spam
stale
testmu
wip
wont fix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/hoppscotch#516
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @bhavukkalra on GitHub (May 14, 2021).
Original GitHub issue: https://github.com/hoppscotch/hoppscotch/issues/1639
Describe the bug
The
fb.jsfile in Helpers Directory can be seen importing variables from.envfile. But the commandprocess.env.GENERAL_VARIABLE_NAMEseems to not be working and The app when cloned and custom environment variables(APP_ID, API_KEY etc) are inserted into the .env file. The file doesn't recognises the input variables and are set toundefinedas a result due to the||operator the default variables are used for building the repo(which passes and app runs on a local environment)(for example
apiKeyis set to"AIzaSyCMsFreESs58-hRxTtiqQrIcimh4i1wbsM"in .env file)To Reproduce
Steps to reproduce the behavior:
with this(i.e removing all the default variables)
Expected behaviour

Now Assuming the .env file is filled correctly, The app should intake the variables from the
.envfile(despite of the removal of the defaults) and show the HomeScreen on localhost(like this)Seen behaviour -

The app after successful compilation gets stuck on the loading when the defaults are removed
Tested on
Additional context
I actually found about this bug when I was also trying to import the environment variables for a Nuxt App and it kept showing
undefinedfor API_KEY(When Client Side rendered) and the actual value(When Server Side Rendered) throughconsole.log()Solution
I also found a solution to this bug and it lies in
@nuxt/dotenvmodule, which requires a little bit of tweaking to thenuxt.config.js. Just wanted to discuss it first with the collaborators to make sure that this is a valid issue before a pull request is made for fixing this@liyasthomas commented on GitHub (May 15, 2021):
Hi @bhavukkalra, thanks for reporting this issue.
We're using NuxtJS RuntimeConfig properties to fetch environment variables from
.envfile in runtime.Reference in
nuxt.congif.jshttps://github.com/hoppscotch/hoppscotch/blob/main/nuxt.config.js#L382-L399
Runtime congif has in-built
dotenvsupport. This error might've been introduced in any latest version bumps of the dependency. We're working on a fix. Thanks for your patience.@liyasthomas commented on GitHub (May 16, 2021):
Hi @bhavukkalra, we've pushed a fix along with a rollback to the
@nuxt/dotenvpackage. The.envfile from the root directory and or environment variables defined in hosting providers like Netlify, Vercel, etc should work now.You can find a sample
.env.examplefile in the root directory with our default environment keys. Rename this file to.envand replace its values with your Firebase config, GTM, and GA keys.Let me know if you run into any other issues.