I specify the port in .env file. In the result I expect to see "{message:'WORKING!'}" on the page, but It just can't open the page There is a code in index.js
require('dotenv').config()
const express = require('express')
const models = require('./models/models')
const cors = require('cors')
const PORT = process.env.PORT || 5000
const app = express()
app.use(cors())
app.use(express.json)
app.get('/', () => {
res.status(200).json({message:'WORKING!'})
})
const start = async () => {
try {
await sequelize.authenticate()
await sequelize.sync()
app.listen(PORT, () => console.log('Port ' + PORT))
} catch (error) {
console.log(error)
}
}
start()
And in .env I have written PORT=5000