Skip to content

Commit

Permalink
Update server.js
Browse files Browse the repository at this point in the history
Change the port to accommodate Azure's environmental variables
  • Loading branch information
JancoEngelbrecht authored Sep 7, 2024
1 parent 16fc7ff commit 1407b25
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions server/server.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
const express = require('express');
const cors = require('cors');
const app = express();
const port = 3000;

// Use the port assigned by Azure, or default to 3000 locally
const port = process.env.PORT || 3000;

// Middleware to enable CORS for security
app.use(cors());
Expand All @@ -23,6 +25,7 @@ app.get('/weather', (req, res) => {
res.json(data);
});

// Start the server
app.listen(port, () => {
console.log(`Server is running at http://localhost:${port}`);
});
console.log(`Server is running on port ${port}`);
});

0 comments on commit 1407b25

Please sign in to comment.