How can I access Heroku's assigned port with sirv? How can I access Heroku's assigned port with sirv? heroku heroku

How can I access Heroku's assigned port with sirv?


Create an .env file (add to .gitignore) with contents:

HOST=localhostPORT=5000

package.json start command:

{  "start": "sirv public --host $HOST --port $PORT"}

When running locally for development execute:

heroku local

This will pickup your env vars from .env

In production, Heroku will provide $HOST and $PORT

$HOST can probably be replaced with hard-coded 0.0.0.0 if desired:

Why is my Node.js app crashing with an R10 error?


By default, the server will only respond to requests from localhost. To allow connections from other computers, edit the sirv commands in package.json to include the option --host 0.0.0.0.

I added this to my package.json and it is successfully getting fully up on heroku!