I want to set the HOST
env var to $HEROKU_APP_NAME.herokuapps.com
on a preview app. It doesn't look like I can do this in app.json
since this is a computed value.
I was hoping to do it in a "postdeploy" script like this
heroku config:set HOST="`heroku config:get HEROKU_APP_NAME -a neon-dev-pr-520`.herokuapps.com"
but it wants to authenticate me as a Heroku user. Alas, this doesn't work either:
export HOST=$HEROKU_APP_NAME.herokuapps.com
Any suggestions?
Heroku Local is a command-line tool to run Procfile-backed apps. It is installed automatically as part of the Heroku CLI. Heroku Local reads configuration variables from a . env file.
Heroku's environment variables are called config vars. To set a config var, navigate to the Settings tab of your app's dashboard, and click Reveal Config Vars.
All heroku config vars will be environment variables, which, in linux environments, can only be strings. So all your variables will be strings once in your app.
Worked out with the assistance of Heroku's awesome support team a few years ago. We needed to set a reflexive environment variable for a middleware (parse-server) to know what to connect to. It's set manually on our Staging and Production apps, but to get it set on our review apps:
My app.json incldues:
"scripts": {
"postdeploy": "bin/bootstrap"
},
...
"env": {
"HEROKU_APP_NAME": {
"required": true
},
"HEROKU_PARENT_APP_NAME": {
"required": true
},
...
bin/bootstrap is:
#!/usr/bin/env bash
echo $HEROKU_APP_NAME
export SERVER_URL=https://$HEROKU_APP_NAME.herokuapp.com/parse
SERVER_URL
is available (and correct) in my review apps. It's been 👍no problems since we implemented.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With