feat(config, layout): add analytics proxy and improve type handling
- Implemented a rewrite rule in the Next.js configuration to proxy analytics requests, bypassing adblockers for Rybbit Analytics. - Enhanced the RootLayout component by correcting the typing of the children prop and improving the structure for better type safety.
This commit is contained in:
1 parent
0a63c3ada0
commit
8f096b9400
2 files changed
+20
-7
No files matched your search
+10
-7
@@ -1,6 +1,8 @@
|
|||||||
import type { Metadata } from "next";
|
import type { Metadata } from "next";
|
||||||
import { Geist, Geist_Mono } from "next/font/google";
|
import { Geist, Geist_Mono } from "next/font/google";
|
||||||
import Script from "next/script";
|
import Script from "next/script";
|
||||||
|
// Importação necessária para corrigir o erro de namespace e tipagem do children
|
||||||
|
import { ReactNode } from "react";
|
||||||
import "./globals.css";
|
import "./globals.css";
|
||||||
|
|
||||||
const geistSans = Geist({
|
const geistSans = Geist({
|
||||||
@@ -69,11 +71,12 @@ export const metadata: Metadata = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function RootLayout({
|
// Interface tipada corretamente
|
||||||
children,
|
interface RootLayoutProps {
|
||||||
}: Readonly<{
|
children: ReactNode;
|
||||||
children: React.ReactNode;
|
}
|
||||||
}>) {
|
|
||||||
|
export default function RootLayout({ children }: Readonly<RootLayoutProps>) {
|
||||||
return (
|
return (
|
||||||
<html lang="pt-BR">
|
<html lang="pt-BR">
|
||||||
<head>
|
<head>
|
||||||
@@ -87,7 +90,6 @@ export default function RootLayout({
|
|||||||
<link rel="preconnect" href="https://wa.me" />
|
<link rel="preconnect" href="https://wa.me" />
|
||||||
<link rel="preconnect" href="https://www.linkedin.com" />
|
<link rel="preconnect" href="https://www.linkedin.com" />
|
||||||
<link rel="preconnect" href="https://github.com" />
|
<link rel="preconnect" href="https://github.com" />
|
||||||
<link rel="preconnect" href="https://analytics.evandro.dev.br" />
|
|
||||||
|
|
||||||
{/* DNS prefetch for additional performance */}
|
{/* DNS prefetch for additional performance */}
|
||||||
<link rel="dns-prefetch" href="//fonts.googleapis.com" />
|
<link rel="dns-prefetch" href="//fonts.googleapis.com" />
|
||||||
@@ -126,8 +128,9 @@ export default function RootLayout({
|
|||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
<Script
|
<Script
|
||||||
src="https://analytics.evandro.dev.br/api/script.js"
|
src="/analytics/api/script.js"
|
||||||
data-site-id="1"
|
data-site-id="1"
|
||||||
|
data-debounce="100"
|
||||||
strategy="afterInteractive"
|
strategy="afterInteractive"
|
||||||
/>
|
/>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
@@ -57,6 +57,16 @@ const nextConfig: NextConfig = {
|
|||||||
];
|
];
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Proxy reverso para bypass de adblockers (Rybbit Analytics)
|
||||||
|
async rewrites() {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
source: "/analytics/:match*",
|
||||||
|
destination: "https://analytics.evandro.dev.br/:match*",
|
||||||
|
},
|
||||||
|
];
|
||||||
|
},
|
||||||
|
|
||||||
// Compressão
|
// Compressão
|
||||||
compress: true,
|
compress: true,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in new issue
Block a user