I just tried my first deploy and got this error: ReferenceError: PORT is not defined
Here’s the code causing the error:
const port = process.env.port || PORT;
PORT is in my .env file, and it’s being used locally. I thought process.env.port would grab Render’s port, but apparently not.
So I added this to the Environment Variables UI:
key: PORT value: 5000
Then I got this error: const port = process.env.port || PORT; // (current: using .env) // with pointer to PORT
So then I added my .env file to the Render UI Secret Files like this:
Filename: .env Contents: code (including PORT=5000)
And now I’m back to this error: ReferenceError: PORT is not defined
So how exactly do I set the port in my code so that it works after Render’s build?