Skip to content

Commit

Permalink
make express example accept port from env
Browse files Browse the repository at this point in the history
  • Loading branch information
nfriedly committed Mar 30, 2021
1 parent 5a06aa3 commit 84cf882
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions examples/express/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ app.get("/", (req, res) =>
);

// start the server and allow unblocker to proxy websockets:
app.listen(process.env.PORT || 8080).on("upgrade", unblocker.onUpgrade);
const port = process.env.PORT || 8080;
app.listen(port).on("upgrade", unblocker.onUpgrade);
// or
// const http = require("http");
// const server = http.createServer(app);
// server.listen(8080);
// server.listen(port);
// server.on("upgrade", unblocker.onUpgrade);

console.log("app listening on port 8080. Test at http://localhost:8080/");
console.log(`unblocker app live at http://localhost:${port}/`);

0 comments on commit 84cf882

Please sign in to comment.