Allow serving other than root of site, fixes #249

auto_join_3.3
Håvar Aambø Fosstveit 2020-05-07 21:03:07 +02:00
parent 02b6c617c5
commit 2373bf44d8
3 changed files with 17 additions and 5 deletions

View File

@ -129,7 +129,8 @@ export default class RoomClient
produce, produce,
forceTcp, forceTcp,
displayName, displayName,
muted muted,
basePath
} = {}) } = {})
{ {
if (!peerId) if (!peerId)
@ -152,6 +153,9 @@ export default class RoomClient
// Whether we force TCP // Whether we force TCP
this._forceTcp = forceTcp; this._forceTcp = forceTcp;
// URL basepath
this._basePath = basePath;
// Use displayName // Use displayName
if (displayName) if (displayName)
store.dispatch(settingsActions.setDisplayName(displayName)); store.dispatch(settingsActions.setDisplayName(displayName));
@ -1719,7 +1723,7 @@ export default class RoomClient
this._screenSharing = ScreenShare.create(this._device); this._screenSharing = ScreenShare.create(this._device);
this._signalingSocket = io(this._signalingUrl); this._signalingSocket = io(this._signalingUrl, { path: this._basePath });
this._spotlights = new Spotlights(this._maxSpotlights, this._signalingSocket); this._spotlights = new Spotlights(this._maxSpotlights, this._signalingSocket);

View File

@ -115,6 +115,13 @@ function run()
const forceTcp = parameters.get('forceTcp') === 'true'; const forceTcp = parameters.get('forceTcp') === 'true';
const displayName = parameters.get('displayName'); const displayName = parameters.get('displayName');
const muted = parameters.get('muted') === 'true'; const muted = parameters.get('muted') === 'true';
const { pathname } = window.location;
let basePath = pathname.substring(0, pathname.lastIndexOf('/'));
if (!basePath)
basePath = '/';
// Get current device. // Get current device.
const device = deviceInfo(); const device = deviceInfo();
@ -134,7 +141,8 @@ function run()
produce, produce,
forceTcp, forceTcp,
displayName, displayName,
muted muted,
basePath
}); });
global.CLIENT = roomClient; global.CLIENT = roomClient;
@ -146,7 +154,7 @@ function run()
<PersistGate loading={<LoadingView />} persistor={persistor}> <PersistGate loading={<LoadingView />} persistor={persistor}>
<RoomContext.Provider value={roomClient}> <RoomContext.Provider value={roomClient}>
<SnackbarProvider> <SnackbarProvider>
<Router> <Router basename={basePath}>
<Suspense fallback={<LoadingView />}> <Suspense fallback={<LoadingView />}>
<React.Fragment> <React.Fragment>
<Route exact path='/' component={ChooseRoom} /> <Route exact path='/' component={ChooseRoom} />

View File

@ -494,7 +494,7 @@ function isPathAlreadyTaken(url)
*/ */
async function runWebSocketServer() async function runWebSocketServer()
{ {
io = require('socket.io')(mainListener); io = require('socket.io')(mainListener, { path: '/' });
io.use( io.use(
sharedSession(session, { sharedSession(session, {