Skip to content

Commit

Permalink
Fix ERR_CONNECTION_REFUSED for Chrome OS
Browse files Browse the repository at this point in the history
When installed on Linux on Chrome OS, the server is not accessible
in Google Chrome out of the box.

To map ports automaticaly, host parameter needs to be passed to a
express app.listen() call.

Fixes udacity#4
  • Loading branch information
mradenovic committed Jan 19, 2020
1 parent cad33c1 commit 6bbfa56
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions config.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
exports.port = process.env.PORT || 5001
exports.host = process.env.HOST || 'localhost'
exports.origin = process.env.ORIGIN || `http://localhost:${exports.port}`
2 changes: 1 addition & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,6 @@ app.post('/contacts', bodyParser.json(), (req, res) => {
}
})

app.listen(config.port, () => {
app.listen(config.port, config.host, () => {
console.log('Server listening on port %s, Ctrl+C to stop', config.port)
})

0 comments on commit 6bbfa56

Please sign in to comment.