Welcome to the Linux Foundation Forum!

Avoid Hard coding PORT

I just want to make sure I understand what an assignment asks when it tells me I can't hard code the PORT variable. Do I assume there's going to be a .env holding the PORT variable that the server calls upon and write the listen function as so:

app.listen(process.env.PORT || 3000)

Or is there something else I have to do like make the .env myself? Also does this apply to implementing a Data Aggregating Service that need certain ports to connect to?

Best Answer

  • Posts: 160
    Answer ✓

    there's to .env involved, but yes the PORT environmental variable is externally set by validation software - as long as your passing process.env.PORT you're good

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Categories

Upcoming Training