fix(routing): [for #168] set router basename (#169)

This commit is contained in:
Jeremy Kahn 2023-09-28 20:57:49 -05:00 committed by GitHub
parent 3fe80f58fd
commit f150915170
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View File

@ -50,11 +50,11 @@
"webrtc-adapter": "^8.2.2" "webrtc-adapter": "^8.2.2"
}, },
"scripts": { "scripts": {
"start": "react-scripts start", "start": "cross-env REACT_APP_HOMEPAGE=$(npm pkg get homepage) react-scripts start",
"start:tracker": "bittorrent-tracker", "start:tracker": "bittorrent-tracker",
"start:streamsaver": "serve -p 3015 node_modules/streamsaver", "start:streamsaver": "serve -p 3015 node_modules/streamsaver",
"dev": "mprocs \"npx cross-env REACT_APP_TRACKER_URL=\"ws://localhost:8000\" REACT_APP_STREAMSAVER_URL=\"http://localhost:3015/mitm.html\" npm run start\" \"npm run start:tracker\" \"npm run start:streamsaver\"", "dev": "mprocs \"npx cross-env REACT_APP_TRACKER_URL=\"ws://localhost:8000\" REACT_APP_STREAMSAVER_URL=\"http://localhost:3015/mitm.html\" npm run start\" \"npm run start:tracker\" \"npm run start:streamsaver\"",
"build": "react-scripts build", "build": "cross-env REACT_APP_HOMEPAGE=$(npm pkg get homepage) react-scripts build",
"test": "react-scripts test", "test": "react-scripts test",
"prepare": "husky install", "prepare": "husky install",
"prettier": "prettier 'src/**/*.js' --write", "prettier": "prettier 'src/**/*.js' --write",

View File

@ -27,6 +27,10 @@ export interface BootstrapProps {
getUuid?: typeof uuid getUuid?: typeof uuid
} }
const homepageUrl = new URL(
process.env.REACT_APP_HOMEPAGE ?? 'https://chitchatter.im/'
)
function Bootstrap({ function Bootstrap({
persistedStorage: persistedStorageProp = localforage.createInstance({ persistedStorage: persistedStorageProp = localforage.createInstance({
name: 'chitchatter', name: 'chitchatter',
@ -99,7 +103,7 @@ function Bootstrap({
} }
return ( return (
<Router> <Router basename={homepageUrl.pathname}>
<StorageContext.Provider value={storageContextValue}> <StorageContext.Provider value={storageContextValue}>
<SettingsContext.Provider value={settingsContextValue}> <SettingsContext.Provider value={settingsContextValue}>
{hasLoadedSettings ? ( {hasLoadedSettings ? (