0

I have a NodeJS app running in port 3000 in an AWS Lightsail Bitnami instance. I have added a domain name (https://mydoaminname.com) to the server and I can access it with https://mydoaminname.com. I want to transfer my NodeJS applications to view https://app.mydoaminname.com and https://mydoaminname.com/app. I tried it using proxy middleware. But still, I can't access it. Do I need to change the domain zone or Bitnami web server settings to meet my requirement?

Please check the below server.js.

const express = require('express');
const { createProxyMiddleware } = require('http-proxy-middleware')
const app = express();
const http = require('http');
const server = http.createServer(app);
const { Server } = require("socket.io");
const io = new Server(server, {
    cors: {
      origin: 'http://localhost:3000',   
    }
});

app.use('/', createProxyMiddleware({ target: 'https://mydoaminname.com/app', changeOrigin: true }));

app.get('/', (req, res) => {
    res.send("kobello v0.0.1")
});

io.on('connection', (socket) => {
    socket.on('create-something', (msg) => {
        io.emit('foo', msg);
        console.log('message: ' + msg);
    });
});

server.listen(3000, () => {
    console.log('listening on *:3000');
});

Bhuvaneshwaran
  • 192
  • 1
  • 2
  • 10
Dmap
  • 129
  • 2
  • 17

0 Answers0