Can't deploy web service

const express = require("express");
const app = express();
const cors = require("cors");
app.use(cors());
app.use(express.json());
app.get("/", (req, res) => {
  res.json("hi");
});
app.listen(3001, () => {
  console.log("listening port 3001");
});

I have this very basic express server and I want to deploy it. Everything looks normal but it consistantly fails. What did I do wrong? Also logs are normal.

Hi there,

Could you try setting your port as per our Express example:

Add:

const port = process.env.PORT || 3001;

and update the listen

app.listen(port, () => { console.log(`listening port ${port}`);});

Hope that helps

Alan

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.