Skip to content

Commit

Permalink
Stop choking if BASE_URL includes origin (fix #979)
Browse files Browse the repository at this point in the history
  • Loading branch information
devinrhode2 committed Aug 11, 2023
1 parent 0dd5953 commit faf3f92
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion packages/start/entry-client/StartClient.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,22 @@ export default () => {
);
}

const BASE_URL = import.meta.env.BASE_URL;
let basePath = BASE_URL;
if (BASE_URL.startsWith("http")) {
try {
// SolidRouter expects a pathname for the `base` prop, not a full URL.
const url = new URL(BASE_URL);
basePath = url.pathname;
} catch (e) {
console.warn('BASE_URL starts with http, but `new URL` failed to parse it. Please check your BASE_URL:', BASE_URL);
}
}

return (
<ServerContext.Provider value={mockFetchEvent}>
<MetaProvider>
<StartRouter base={import.meta.env.BASE_URL} data={dataFn}>
<StartRouter base={basePath} data={dataFn}>
<Root />
</StartRouter>
</MetaProvider>
Expand Down

0 comments on commit faf3f92

Please sign in to comment.