Browse Source

Fix basePath references.

dev
Mike Cao 8 months ago
parent
commit
23d4d13c9d
5 changed files with 17 additions and 9 deletions
  1. +5
    -1
      components/forms/ShareUrlForm.js
  2. +3
    -1
      components/forms/TrackingCodeForm.js
  3. +1
    -1
      components/layout/Layout.js
  4. +3
    -1
      hooks/useShareToken.js
  5. +5
    -5
      pages/_app.js

+ 5
- 1
components/forms/ShareUrlForm.js View File

@ -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
/>
</FormRow>


+ 3
- 1
components/forms/TrackingCodeForm.js View File

@ -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 (
<FormLayout>
@ -22,7 +24,7 @@ export default function TrackingCodeForm({ values, onClose }) {
rows={3}
cols={60}
spellCheck={false}
defaultValue={`<script async defer data-website-id="${values.website_uuid}" src="${document.location.origin}/umami.js"></script>`}
defaultValue={`<script async defer data-website-id="${values.website_uuid}" src="${document.location.origin}${basePath}/umami.js"></script>`}
readOnly
/>
</FormRow>


+ 1
- 1
components/layout/Layout.js View File

@ -8,7 +8,7 @@ export default function Layout({ title, children, header = true, footer = true }
<>
<Head>
<title>umami{title && ` - ${title}`}</title>
<link rel="icon" href="/favicon.ico" />
<link rel="icon" href="favicon.ico" />
<link
href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600&display=swap"
rel="stylesheet"


+ 3
- 1
hooks/useShareToken.js View File

@ -1,14 +1,16 @@
import { useEffect } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { useRouter } from 'next/router';
import { get } from 'lib/web';
import { setShareToken } from 'redux/actions/app';
export default function useShareToken(shareId) {
const { basePath } = useRouter();
const dispatch = useDispatch();
const shareToken = useSelector(state => 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));


+ 5
- 5
pages/_app.js View File

@ -29,11 +29,11 @@ export default function App({ Component, pageProps }) {
return (
<Provider store={store}>
<Head>
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png" />
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png" />
<link rel="manifest" href="/site.webmanifest" />
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5" />
<link rel="apple-touch-icon" sizes="180x180" href="apple-touch-icon.png" />
<link rel="icon" type="image/png" sizes="32x32" href="favicon-32x32.png" />
<link rel="icon" type="image/png" sizes="16x16" href="favicon-16x16.png" />
<link rel="manifest" href="site.webmanifest" />
<link rel="mask-icon" href="safari-pinned-tab.svg" color="#5bbad5" />
<meta name="msapplication-TileColor" content="#da532c" />
<meta name="theme-color" content="#ffffff" />
</Head>


Loading…
Cancel
Save