From a57654f05aa99bc3c6651082fe0a5f02c5ff7a53 Mon Sep 17 00:00:00 2001 From: Max Leiter Date: Sun, 6 Mar 2022 17:29:34 -0800 Subject: [PATCH] Fix basePath? --- client/components/Link.tsx | 5 +++-- client/next.config.js | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/client/components/Link.tsx b/client/components/Link.tsx index 6bb16a77..a57ed0c7 100644 --- a/client/components/Link.tsx +++ b/client/components/Link.tsx @@ -3,8 +3,9 @@ import { useRouter } from "next/router"; const Link = (props: LinkProps) => { const { basePath } = useRouter(); - const propHrefWithoutLeadingSlash = props.href ? props.href.replace(/^\//, "") : props.href; - const href = basePath ? `/${basePath}/${propHrefWithoutLeadingSlash}` : props.href; + const propHrefWithoutLeadingSlash = props.href && props.href.startsWith("/") ? props.href.substr(1) : props.href; + const href = basePath ? `${basePath}/${propHrefWithoutLeadingSlash}` : props.href; + console.log(href) return } diff --git a/client/next.config.js b/client/next.config.js index 8de8d48a..32953200 100644 --- a/client/next.config.js +++ b/client/next.config.js @@ -1,6 +1,7 @@ /** @type {import('next').NextConfig} */ const nextConfig = { reactStrictMode: true, + basePath: "/drift", async rewrites() { return [ {