1
Fork 0

Merge pull request #838 from djvaldez/fix-custom-basepath

Fix custom basepath in React components
This commit is contained in:
Viktor Strate Kløvedal 2023-05-01 15:02:36 +02:00 committed by GitHub
commit c38f8a43c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 3 deletions

View File

@ -12,7 +12,7 @@ export const INITIAL_SETUP_QUERY = gql`
export function login(token: string) { export function login(token: string) {
saveTokenCookie(token) saveTokenCookie(token)
window.location.href = '/' window.location.href = `${import.meta.env.BASE_URL}`
} }
export const Container = styled.div.attrs({ className: 'mt-20' })`` export const Container = styled.div.attrs({ className: 'mt-20' })``

View File

@ -13,7 +13,10 @@ const placeholder =
const getProtectedUrl = (url?: string) => { const getProtectedUrl = (url?: string) => {
if (url == undefined) return undefined if (url == undefined) return undefined
const imgUrl = new URL(url, location.origin) const imgUrl = new URL(
`${import.meta.env.BASE_URL}${url}`.replace(/\/\//g, '/'),
location.origin
)
const tokenRegex = location.pathname.match(/^\/share\/([\d\w]+)(\/?.*)$/) const tokenRegex = location.pathname.match(/^\/share\/([\d\w]+)(\/?.*)$/)
if (tokenRegex) { if (tokenRegex) {

View File

@ -16,7 +16,7 @@ setupLocalization()
const Main = () => ( const Main = () => (
<ApolloProvider client={client}> <ApolloProvider client={client}>
<Router> <Router basename={import.meta.env.BASE_URL}>
<SidebarProvider> <SidebarProvider>
<App /> <App />
</SidebarProvider> </SidebarProvider>