1

I have an Electron app that uses an Angular frontend served at port 4201 and a NodeJS backend. I want to make the app work multi-instance, which would require changing ports (I'm not sure yet whether to do this randomly or some other way). While it's easy to change the frontend from one port to another, the NodeJS backend remains at port 3000 no matter what I do. What, if anything can I do to move it? In Main.js I've tried

...
var routes = require('./backend_routes/query'); //importing route
routes(backend); //register the route
backend.listen(3001);
var win, serve;
var args = process.argv.slice(1);
serve = args.some(function (val) { return val === '--serve'; });
...

and the backend just keeps listening at port 3000.

EDIT:

There was a question about the code in backend_routes/query . This is that code:

//all the backend routes are specified here
'use strict';
module.exports = function(app) {
    var query = require('../backend_controllers/query');
    var reports = require('../backend_controllers/reports');
    //Routes
    app.route('/query').get(query.execute);
    app.route('/databaselist').get(query.databaselist);
    app.route('/redodatabaseconnection').get(query.redodatabaseconnection);
    app.route('/lookupcollections').get(query.lookupcollections);
    app.route('/lookupcollection').get(query.lookupcollection);
    app.route('/showhistory').get(query.showhistory);
  ...
 }

6
  • Where is your server code?
    – Marc
    Mar 23, 2022 at 15:50
  • That is the server code. iI's NodeJS. NodeJS is the server (aka backend). It's a server and a client together in one big Electron app. Mar 23, 2022 at 15:57
  • I know. but if you call listen(3001) and nothing changes, then its not the right part... Where is your real server code?! Whats the content of backend_routes/query?
    – Marc
    Mar 23, 2022 at 15:59
  • I updated the question to show that code as well. Mar 23, 2022 at 18:14
  • Wha is the backend object? Please add your full code
    – Marc
    Mar 23, 2022 at 18:33

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.