Skip to content

Commit

Permalink
Fixed the App URL for HTTP
Browse files Browse the repository at this point in the history
  • Loading branch information
subhrashisdas committed Apr 22, 2021
1 parent 10107b8 commit 0f5e7e0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
8 changes: 4 additions & 4 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@ const path = require('path');
const http = require('http');
const app = express();
const server = http.createServer(app);
const io = require('socket.io').listen(server);
const io = require('socket.io').listen(server, { path: '/talk/socket.io'});

// Server all the static files from www folder
app.use(express.static(path.join(__dirname, 'www')));
app.use('/talk/', express.static(path.join(__dirname, 'www')));

// Get PORT from env variable else assign 3000 for development
const PORT = process.env.PORT || 3000;
server.listen(PORT, null, function() {
console.log('Listening on port ' + PORT);
});

app.get('/legal', (req, res) => res.sendFile(path.join(__dirname, 'www/legal.html')));
app.get('/talk/legal', (req, res) => res.sendFile(path.join(__dirname, 'www/legal.html')));

// All URL patterns should served with the same file.
app.get(['/', '/:room'], (req, res) => res.sendFile(path.join(__dirname, 'www/index.html')));
app.get(['/talk/:room'], (req, res) => res.sendFile(path.join(__dirname, 'www/main.html')));

const channels = {};
const sockets = {};
Expand Down
6 changes: 2 additions & 4 deletions www/index.html → www/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,14 @@
<link rel="stylesheet" href="style.css" />
<script src="https://kit.fontawesome.com/d2f1016e6f.js" crossorigin="anonymous"></script>
<script src="https://webrtc.github.io/adapter/adapter-latest.js"></script>
<script src="/socket.io/socket.io.js"></script>
<script src="script.js"></script>
<script src="/talk/socket.io/socket.io.js"></script>
<script src="/talk/script.js"></script>
<title>Talk - A free video call app for the web</title>
</head>

<body onload="init()">
<div id="message">
Share the URL of this page with your friends to start talking.<br />
<a href="http://github.com/vasanthv/talk" target="_blank">Source code</a> &middot;
<a href="/legal" target="_blank">Legal</a>
</div>
<div id="allowaccess">
<div id="logo" style="margin:auto;">
Expand Down
5 changes: 2 additions & 3 deletions www/script.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const appURL = () => {
const protocol = "http" + (location.hostname == "localhost" ? "" : "s") + "://";
return protocol + location.hostname + (location.hostname == "localhost" ? ":3000" : "");
return location.protocol + "//" + location.hostname + "/" + "talk";
};
const getRoomName = () => {
let roomName = location.pathname.substring(1);
Expand Down Expand Up @@ -50,7 +49,7 @@ var peerMediaElements = {}; /* keep track of our <video> tags, indexed by peer_i

function init() {
console.log("Connecting to signaling server");
signalingSocket = io(SIGNALING_SERVER);
signalingSocket = io(SIGNALING_SERVER, { path: '/talk/socket.io/'});
signalingSocket = io();

signalingSocket.on("connect", function() {
Expand Down

0 comments on commit 0f5e7e0

Please sign in to comment.