Skip to content

Commit

Permalink
Fix basePath references.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikecao committed Jan 14, 2021
1 parent dfe157b commit 23d4d13
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 9 deletions.
6 changes: 5 additions & 1 deletion components/forms/ShareUrlForm.js
Original file line number Diff line number Diff line change
@@ -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 (
Expand All @@ -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>
Expand Down
4 changes: 3 additions & 1 deletion components/forms/TrackingCodeForm.js
Original file line number Diff line number Diff line change
@@ -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>
Expand All @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion components/layout/Layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 3 additions & 1 deletion hooks/useShareToken.js
Original file line number Diff line number Diff line change
@@ -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));
Expand Down
10 changes: 5 additions & 5 deletions pages/_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down

0 comments on commit 23d4d13

Please sign in to comment.