From 23d4d13c9d105623dff15a694c9849509ce52012 Mon Sep 17 00:00:00 2001 From: Mike Cao Date: Thu, 14 Jan 2021 00:34:51 -0800 Subject: [PATCH] Fix basePath references. --- components/forms/ShareUrlForm.js | 6 +++++- components/forms/TrackingCodeForm.js | 4 +++- components/layout/Layout.js | 2 +- hooks/useShareToken.js | 4 +++- pages/_app.js | 10 +++++----- 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/components/forms/ShareUrlForm.js b/components/forms/ShareUrlForm.js index dbb1b656..a77d3fbc 100644 --- a/components/forms/ShareUrlForm.js +++ b/components/forms/ShareUrlForm.js @@ -1,11 +1,13 @@ import React, { useRef } from 'react'; import { FormattedMessage } from 'react-intl'; +import { useRouter } from 'next/router'; import Button from 'components/common/Button'; import FormLayout, { FormButtons, FormRow } from 'components/layout/FormLayout'; import CopyButton from 'components/common/CopyButton'; export default function TrackingCodeForm({ values, onClose }) { const ref = useRef(); + const { basePath } = useRouter(); const { name, share_id } = values; return ( @@ -23,7 +25,9 @@ export default function TrackingCodeForm({ values, onClose }) { rows={3} cols={60} spellCheck={false} - defaultValue={`${document.location.origin}/share/${share_id}/${encodeURIComponent(name)}`} + defaultValue={`${ + document.location.origin + }${basePath}/share/${share_id}/${encodeURIComponent(name)}`} readOnly /> diff --git a/components/forms/TrackingCodeForm.js b/components/forms/TrackingCodeForm.js index a8d5a344..fd679ab2 100644 --- a/components/forms/TrackingCodeForm.js +++ b/components/forms/TrackingCodeForm.js @@ -1,11 +1,13 @@ import React, { useRef } from 'react'; import { FormattedMessage } from 'react-intl'; +import { useRouter } from 'next/router'; import Button from 'components/common/Button'; import FormLayout, { FormButtons, FormRow } from 'components/layout/FormLayout'; import CopyButton from 'components/common/CopyButton'; export default function TrackingCodeForm({ values, onClose }) { const ref = useRef(); + const { basePath } = useRouter(); return ( @@ -22,7 +24,7 @@ export default function TrackingCodeForm({ values, onClose }) { rows={3} cols={60} spellCheck={false} - defaultValue={``} + defaultValue={``} readOnly /> diff --git a/components/layout/Layout.js b/components/layout/Layout.js index b16a0717..2d283d2f 100644 --- a/components/layout/Layout.js +++ b/components/layout/Layout.js @@ -8,7 +8,7 @@ export default function Layout({ title, children, header = true, footer = true } <> umami{title && ` - ${title}`} - + state.app.shareToken); async function loadToken(id) { - const { data } = await get(`/api/share/${id}`); + const { data } = await get(`${basePath}/api/share/${id}`); if (data) { dispatch(setShareToken(data)); diff --git a/pages/_app.js b/pages/_app.js index dcdddee8..edfd2f5c 100644 --- a/pages/_app.js +++ b/pages/_app.js @@ -29,11 +29,11 @@ export default function App({ Component, pageProps }) { return ( - - - - - + + + + +