I have a simple API server running on Node.js/Express
like below:
server.js
const express = require('express');
const cors = require('cors');
const app = express();
var corsOptions = {
origin: 'https://localhost:8081',
}
// middlewares
app.use(cors(corsOptions));
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
// testing api
app.get('/', (req, res) => {
res.json({message: 'hello from API'})
})
const PORT = process.env.PORT || 8080;
// server
app.listen(PORT, () => {
console.log(`Server is running on port ${PORT}`);
});
It works normally both in the browser and Postman.
But when I test it on Insomnia it always Server is up and running.
I've downloaded the newest version and reinstalling using it, but it's still not working as expected and keeps returning the Server is up and running.
message.
Did I miss something or there is a configuration to resolve this problem? Thanks