Skip to content

Commit

Permalink
Proxy analytics & speed insights data
Browse files Browse the repository at this point in the history
So adblocker will not block it
  • Loading branch information
tobiaslins committed Oct 21, 2024
1 parent d5cebd7 commit d5c41dd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
21 changes: 21 additions & 0 deletions next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,27 @@ const nextConfig = {
},
],
},
async rewrites() {
return [
{
source: "/insights/vitals.js",
destination:
"https://cdn.vercel-insights.com/v1/speed-insights/script.js",
},
{
source: "/insights/events.js",
destination: "https://cdn.vercel-insights.com/v1/script.js",
},
{
source: "/hfi/events/:slug*",
destination: "https://vitals.vercel-insights.com/v1/:slug*",
},
{
source: "/hfi/vitals/:slug*",
destination: "https://vitals.vercel-insights.com/v2/:slug*",
},
];
},
};

export default nextConfig;
4 changes: 2 additions & 2 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ export default async function RootLayout({
<WelcomeToast />
</Suspense>

<Analytics />
<SpeedInsights />
<Analytics scriptSrc="/insights/events.js" endpoint="/hfi/events" />
<SpeedInsights scriptSrc="/insights/vitals.js" endpoint="/hfi/vitals" />
</body>
</html>
);
Expand Down

0 comments on commit d5c41dd

Please sign in to comment.