Hi I was trying to deploy my rtmp server to Heroku but first I had some issues that I hard coded the ports instead of making env file. I use concurrently to run two scripts. My file structure is
rtmp-server
├── client
└── rtmp
rtmp needs 2ports (1935 & 8888) & client need 2ports (3000 & 3001) as well
I have few questions.
- Do I have to use Dotenv in root or in subdirs (client & rtmp both separately)
- How can I use values of Dotenv in
package.json
In your
package.json
you could do something likecommand to serve $PORT
to get the PORT variableBut there is a better way of handling this by reading the
PORT
variable in your code like so:Here 3000 is just the fallback value if
process.env.PORT
isundefined
. This is useful while developing