Hello everyone and happy holidays.
Was wondering if you could maybe give me some hints on how to route traffic to different ports in glitch.
I’m pretty new to this, tried googling my way to the goal… But here i am
I was hoping to achieve this result:
Copied from user etamponi from thread What's the port range users have at Glitch?
(Sadly im still missing something even after reading the post)
https://your-project.glitch.me/serviceA/:path -> http://localhost:4000/:path
https://your-project.glitch.me/serviceB/:path -> http://localhost:5000/:path
https://your-project.glitch.me/serviceC/:path -> http://localhost:6000/:path
I have 3 node files running at the same time on different ports.
I did a curl http://localhost:3002/login
and curl http://localhost:3001/MessagingClient
from the terminal in glitch and got something back.
But when i try to browse my app https://messaginmountaineer.glitch.me/login
am getting Cannot GET /login
What am I missing?
App.js
const dotenv = require("dotenv").config();
const express = require("express");
const proxy = require('express-http-proxy');
const morgan = require("morgan")
require("./testLoginExpress");
require("./MessagingServer");
const app = require("express")();
const http = require("http").Server(app);
const io = require("socket.io")(http);
const port = process.env.PORT || 3000;
app.use(morgan("dev"))
app.use('/login', proxy("http://localhost:3002/Login"))
app.use('/chat', proxy("http://localhost:3001/MessagingClient"))
http.listen(port, () => {
console.log(`App login server running at http://localhost:${port}/`);
});
testLoginExpress.js
const dotenv = require("dotenv").config();
const proxy = require('express-http-proxy');
const express = require("express");
const morgan = require("morgan");
const app = require("express")();
const http = require("http").Server(app);
const io = require("socket.io")(http);
const port = process.env.PORT2|| 3002
const { readFromDB } = require("./mongoDB");
app.use(morgan("dev"));
app.use(express.static(__dirname +"public"));
app.get("/Login", (req, res) => {
res.sendFile(__dirname + "/public2/LoginClient.html");
});
http.listen(port, () => {
console.log(`Express login server running at http://localhost:${port}/`);
});
MessagingServer.js
const dotenv = require("dotenv").config();
const express = require("express");
const proxy = require('express-http-proxy');
const app = require("express")();
const http = require("http").Server(app);
const io = require("socket.io")(http);
const port = process.env.PORT || 3001;
require("./testLoginExpress");
const { readFromDB } = require("./mongoDB");
app.use(express.static(__dirname + "/public/"));
app.get("/MessagingClient", (req, res) => {
res.sendFile(__dirname + "/public/MessaginClient.html");
});
//some logic
http.listen(port, () => {
console.log(`Socket.IO server running at http://localhost:${port}/`);
});