maria maria - 3 months ago 11
Node.js Question

Mean stack / node website port

When im using node / mean stack, i always needs to visit the url like

example.com:3000


is there a way to remove the port in the url, and still make it works?

to like:

example.com

Answer

Swap your port to listen to port 80

HTTP is 80

HTTPS is 443

Example:

const express = require( 'express' ),
      app = express();

app.get( '/', function( req, res ) {
    res.send( 'hello world' );
} );

app.listen( 80 );
Comments