What are the other heroku environment variables?

前端 未结 4 1903
萌比男神i
萌比男神i 2020-12-28 12:50

When setting up a server, I noticed that the environment variable process.env.PORT is used. Are there any other variables like this? Where can I see all of them?

相关标签:
4条回答
  • 2020-12-28 13:11

    The following command will display all of the environment variables, not just those visible from heroku config:

    heroku run printenv
    
    0 讨论(0)
  • 2020-12-28 13:12

    The command is

    heroku config
    

    You can read more here https://devcenter.heroku.com/articles/config-vars

    0 讨论(0)
  • 2020-12-28 13:13

    See https://devcenter.heroku.com/articles/config-vars: there's a command that appears to tell you what your environment variables are.

    $ heroku config
    

    See if that works for you.

    EDIT: it appears the heroku docs linked above are wrong. Try this:

    $ heroku config -s --app <appname>
    
    0 讨论(0)
  • 2020-12-28 13:18

    heroku config does not show PORT. So, it's incomplete if you need everything. This will create a one-off dyno and show everything.

    From here: https://devcenter.heroku.com/articles/getting-started-with-nodejs#console

    Run a console in a one-off dyno, then at the > prompt, type "console.log(process.env)":

    $ heroku run node
    Running `node` attached to terminal... up, run.4778
    > console.log(process.env
    ... )
    { BUILDPACK_URL: 'https://github.com/MichaelJCole/heroku-buildpack-nodejs.git#wintersmith',
      TERM: 'xterm',
      SENDGRID_USERNAME: 'unicorns@heroku.com',
      COLUMNS: '80',
      DYNO: 'run.4778',
      PATH: '/app/bin:/app/node_modules/.bin:bin:node_modules/.bin:/usr/local/bin:/usr/bin:/bin',
      PWD: '/app',
      PS1: 'fairydust',
      LINES: '22',
      SHLVL: '1',
      HOME: '/app',
      SENDGRID_PASSWORD: 'ponies',
      PORT: '52031',
      _: '/app/bin/node' }
    undefined
    
    0 讨论(0)
提交回复
热议问题