From faf3f921aa88c044e7213513f518306574cac46a Mon Sep 17 00:00:00 2001 From: devinrhode2 Date: Thu, 10 Aug 2023 23:34:47 -0500 Subject: [PATCH] Stop choking if BASE_URL includes origin (fix #979) --- packages/start/entry-client/StartClient.tsx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/start/entry-client/StartClient.tsx b/packages/start/entry-client/StartClient.tsx index 086f653ee..10fb95790 100644 --- a/packages/start/entry-client/StartClient.tsx +++ b/packages/start/entry-client/StartClient.tsx @@ -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 ( - +