mirror of
https://github.com/ianramzy/decentralized-video-chat.git
synced 2025-02-20 23:15:01 +08:00
server handles bad routing / params now
This commit is contained in:
parent
5df20e1b4c
commit
510d11b457
@ -663,16 +663,6 @@ pipVideo.addEventListener("leavepictureinpicture", () => {
|
||||
//
|
||||
|
||||
function startUp() {
|
||||
// strip url parameters
|
||||
if (url.indexOf("?") > -1) {
|
||||
window.location.href = url.split("?")[0];
|
||||
}
|
||||
|
||||
// if no chat room provided go back to newroom
|
||||
if (window.location.pathname === "/room") {
|
||||
window.location.href = "/landing/newroom";
|
||||
}
|
||||
|
||||
// Redirect unsupported browsers
|
||||
if (
|
||||
!isWebRTCSupported ||
|
||||
|
18
server.js
18
server.js
@ -10,6 +10,7 @@ var http = require("http").createServer(app);
|
||||
var io = require("socket.io")(http);
|
||||
var path = require("path");
|
||||
var public = path.join(__dirname, "public");
|
||||
const url = require("url"); // built-in utility
|
||||
|
||||
// enable ssl redirect
|
||||
app.use(sslRedirect());
|
||||
@ -22,14 +23,27 @@ app.get("/newroom", function (req, res) {
|
||||
res.sendFile(path.join(public, "newroom.html"));
|
||||
});
|
||||
|
||||
app.get("/room/", function (req, res) {
|
||||
res.redirect("/");
|
||||
});
|
||||
|
||||
app.get("/room/*", function (req, res) {
|
||||
res.sendFile(path.join(public, "chat.html"));
|
||||
if (Object.keys(req.query).length > 0) {
|
||||
logIt("redirect:" + req.url + " to " + url.parse(req.url).pathname);
|
||||
res.redirect(url.parse(req.url).pathname);
|
||||
} else {
|
||||
res.sendFile(path.join(public, "chat.html"));
|
||||
}
|
||||
});
|
||||
|
||||
app.use(express.static("public"));
|
||||
|
||||
function logIt(msg, room) {
|
||||
console.log(room + ": " + msg);
|
||||
if (room) {
|
||||
console.log(room + ": " + msg);
|
||||
} else {
|
||||
console.log(msg);
|
||||
}
|
||||
}
|
||||
|
||||
// When a socket connects, set up the specific listeners we will use.
|
||||
|
Loading…
x
Reference in New Issue
Block a user