I have a node.js server that has HTTP CRUD functions to my mongoDB.
And an Android application that sends requests though those functions.
I would like to ensure that my server will answer requests from specific origins.
For example: only answer requests from the android app, or my pc postman's requests.
How can I ensure that no one else sending requests using the same urls and ports will get answered?
This is my server.js file:
const express = require('express');
const MongoClient = require('mongodb');
const bodyParser = require('body-parser');
var db = require('./config/db');
var app = express();
const port = 8000;
app.use(bodyParser.json());
MongoClient.connect(db.url, (err, database) => {
if (err) return console.log(err)
db = database.db("getremp")
require('./app/routes')(app, db);
app.listen(process.env.PORT || port, () => {
console.log("Express server listening on port %d in %s mode - We Are lIVE!",app.settings.env.port, app.settings.env);
});
})
and my index.js:
const noteRoutes = require('./note_routes');
module.exports = function (app, db) {
noteRoutes(app, db);
};