Hi everyone,
i’am following currently the tutorial guide for the “giphy app”. Everything works fine except the use of environment variables in the tunneling case. In step 5 i’am asked to set the giphy-api-key as env.-variable with prefix.
Neither i understand the following (from the tutorial):
Start a tunnel with access to your GIPHY API key by running:
FORGE_USER_VAR_GIPHY_API_KEY=<your-giphy-api-key> forge tunnel
… nor i understand the documentation for environment:
- Set the value of
MY_KEY
by prefixing FORGE_USER_VAR_
to the variable name, then running the following command in your terminal:
export FORGE_USER_VAR_MY_KEY=test
Has anybody an idea, whats meant by this? Wich terminal should i use to set the variable?
Best Regards
Gunther
Hi @GuntherPelzer,
Welcome to CDAC!
When you are tunneling (ie running your Forge app locally), your app does not have access to the environment variables you define with: forge variables:set
. To work around this, the locally running Forge app instead looks for environment variables on your local machine that start with FORGE_USER_VAR_
and exposes them to your app.
So, if you your Forge app uses a variable called GIPHY_API_KEY
you can make that available in two ways, depending on where your app is running. If you are running locally (ie tunneling), you need to set that variable on your local machine which is what the tutorial does here: FORGE_USER_VAR_GIPHY_API_KEY=<your-giphy-api-key> forge tunnel
If you are deploying your app to Forge using Forge deploy, you set the variable using the Forge CLI like in Step 7: forge variables:set GIPHY_API_KEY <your-giphy-api-key>
Hope that helps, if not let me know what is unclear and I’ll try to explain it a bit better.
Best Regards,
Oliver
1 Like
Hi Oliver,
thanks for the answer, i picked “… set that variable on your local machine …” from it, and so i used on my Windows OS in my cmd-terminal:
set FORGE_USER_VAR_GIPHY_API_KEY=<your-giphy-api-key>
worked for me…
BG
3 Likes