Skip to content

Commit

Permalink
Merge pull request #13 from browser-vm/autopilot/10-20250210144941288
Browse files Browse the repository at this point in the history
Fix: Ensure `port` variable is defined before usage in route handler
  • Loading branch information
browser-vm authored Feb 10, 2025
2 parents d1230a9 + d858d25 commit e6c9fe1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ app.use('/baremux/', express.static(baremuxPath));
// Configure Ultraviolet
const uv = new Ultraviolet(uvConfig);

// Initialize port variable
let port = parseInt(process.env.PORT || '');
if (isNaN(port)) port = 8080;

// Generate proxied URL
app.get('/generate-proxy-url', (req, res) => {
const serviceUrl = req.query.url;
Expand Down Expand Up @@ -64,10 +68,6 @@ server.on('upgrade', (req, socket, head) => {
socket.end();
});

let port = parseInt(process.env.PORT || '');

if (isNaN(port)) port = 8080;

server.on('listening', () => {
const address = server.address();

Expand Down

0 comments on commit e6c9fe1

Please sign in to comment.