0

I am trying to make a web page for my node js project. Currently I have

const express = require('express');
const app = express();
const http = require('http');
const path = require('path');

const httpserver = http.Server(app);
const gamedirectory = path.join(__dirname, "public");
app.use(express.static(gamedirectory));
httpserver.listen(3000);

But I don't have the ip and port of my project. How do I get these with node js?

Luuk
  • 641
  • 4
  • 12
  • 1
    Does this answer your question? [Get local IP address in Node.js](https://stackoverflow.com/questions/3653065/get-local-ip-address-in-node-js) – Akio Mar 22 '21 at 16:47

1 Answers1

1

Use this

let ip = require("ip");
console.log( ip.address() );

This question is already answered Get local IP address in Node.js

Akio
  • 721
  • 2
  • 6
  • 21