1

I created a mean stack application, I am deploying it in a virtual machine the problem is that I need to change the localhost(localhost:4200) address to the ip of the machine 10.10.10.15(10.10.10.15:4200) I don't know how to do it

const path = require("path");
const express = require("express")
const mongoose = require("mongoose")
const db = require("./db/db")
const header_middleware = require("./middlewares/header")

const postRouter = require("./Routes/post");
const userRoutes = require("./Routes/user");
const profileRoutes = require("./Routes/profile");

var cors = require('cors');


const app = express()
app.use(cors({origin: '*'}));
const PORT = process.env.PORT || 3000


app.use(express.json())
app.use(header_middleware)
const directory = path.join(__dirname, './images');
app.use("/images", express.static(directory));
// app.use("/", express.static(path.join(__dirname, 'angular')));

app.use("/api/posts", postRouter)
app.use("/api/user", userRoutes);
app.use("/api/profile", profileRoutes);


app.get('/test', (req, res) => {
    res.send('Hello World!')
  })

app.listen(PORT, (req,res) => {
    
    console.log(`app is listening to PORT ${PORT}`)
})
ben77
  • 33
  • 1
  • 4

1 Answers1

0

Instead of using your ip you can use your computer-name:4300 in your browser for example laptop-xxxxx:4300. To find your computer name you can go to about in your settings and it will say the name of your computer. If that doesn’t work check this answer out: https://stackoverflow.com/a/34659560/11365636

Someone21
  • 91
  • 10
  • app.listen(PORT,"10.10.10.15", (req,res) => { console.log(`app is listening to PORT ${PORT}`) }) not work – ben77 Dec 13 '20 at 14:40