Skip to content

Commit 7d4c00c

Browse files
committed
fix: using proxy for analytics
1 parent 71adcec commit 7d4c00c

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

next.config.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ const nextConfig = {
1111
],
1212
deviceSizes: [1080, 1920],
1313
},
14+
async rewrites() {
15+
return [
16+
{
17+
source: "/script.analytics.js",
18+
destination: "https://cloud.umami.is/script.js",
19+
},
20+
];
21+
},
1422
};
1523

1624
module.exports = nextConfig;

src/pages/_document.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ export default function Document() {
44
return (
55
<Html lang="en">
66
<Head>
7-
<script
8-
async
9-
src="https://analytics.umami.is/script.js"
10-
data-website-id={process.env.NEXT_PUBLIC_UMAMI_WEBSITE_ID}
11-
></script>
7+
{process.env.NODE_ENV === "production" && (
8+
<script
9+
defer
10+
src="/script.analytics.js"
11+
data-website-id={process.env.NEXT_PUBLIC_UMAMI_ID}
12+
/>
13+
)}
1214
</Head>
1315
<body>
1416
<Main />

0 commit comments

Comments
 (0)