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,
forceTcp,
displayName,
muted
muted,
basePath
} = {})
{
if (!peerId)
@ -152,6 +153,9 @@ export default class RoomClient
// Whether we force TCP
this._forceTcp = forceTcp;
// URL basepath
this._basePath = basePath;
// Use displayName
if (displayName)
store.dispatch(settingsActions.setDisplayName(displayName));
@ -1719,7 +1723,7 @@ export default class RoomClient
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);

View File

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

View File

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