2

I have a nose.js pipeline on Heroku with review apps spwaned automatically for pull requests.

How can I get the url of heroku apps (https://xyz.herokuapp.com) at runtime using node.js or do I have to hardcode the value as an environment variable.

1 Answer 1

1

You should be able to get the xyz part of the URL from the HEROKU_APP_NAME environment variable:

process.env.HEROKU_APP_NAME

Heroku sets this environment variable automatically for review apps if you specify it in your app.json with

"env":{
  "HEROKU_APP_NAME": {
    "required": true
  },
  "HEROKU_PARENT_APP_NAME": {
    "required": true
  }
}

See https://devcenter.heroku.com/articles/github-integration-review-apps#heroku_app_name-and-heroku_parent_app_name

You can also get it for non-review apps I think see, https://devcenter.heroku.com/articles/dyno-metadata

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.