Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49240

Electron app with included Node express server

$
0
0

Hey there.

I try to manage to get a Node server running inside the electron app.
What should be possible as far I found out.

I made a express app.js witch is included in the index.js
The server is listening to port 3000.

app.js :

... other code

const app = express();
const publicPath = path.resolve(__dirname, '../dist');
const port = 3000;
var router = (module.exports = express.Router());

router.post('/api/xml', function (req, res) {
    if (err) {
      log.warn('Error: ' + err);
      return res.end('Error: ' + err);
    } else {
      log.info('Request body: ' + req.body);
    }
  });

const server = app.listen(port, () =>
    log.info(`Express server listening on port ${port}`)  <-- Which is called
);

... other code

But if I send a http request from the app

... other code

const request = new HttpRequest(
      'POST',
      'http://localhost:3000/api/xml',
      formData,
      options
);

return this.http.request(request);

... other code

I get the error inside the dev tools (electron):
“Failed to load resource: net::ERR_CONNECTION_REFUSED”

I cannot find a good way to debug this.
Any advice?

Is localhost the right host inside electron?

Thanks in advance!

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 49240

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>