My app is using angular in the client and nodejs as the backend, but I have some problem to configure them properly in production on heroku.
In development I run my nodejs server on port 3000 and send all the http requests from the angular client to http://localhost:3000
and its works very well. but when I deploy my nodejs server with my angular client files under the dist directory, heroku lifts the server on random port and all my http requests to http://localhost:3000
failed. how I can determine the node port on heroku or how I can get it in my angular client?
Code on server:
let port = normalizePort(process.env.PORT || '3000');
app.set('port', port);
const server = http.createServer(app);
server.listen(port, () => console.log('app listening on port '
+ port));
server.on('error', onError);
server.on('listening', onListening);
Code on client:
export const environment = {
production: true,
serverUrl: 'http://localhost:3000'
};
Aucun commentaire:
Enregistrer un commentaire