From 8bc3dcc3496382e8256e5f0161c555015f4a652a Mon Sep 17 00:00:00 2001 From: JiPai <3956400+PaiJi@users.noreply.github.com> Date: Sun, 2 Jun 2024 23:49:08 +0800 Subject: [PATCH] fix: fix api payload parse (#190) --- src/pages/_app.tsx | 4 ---- src/pages/_document.tsx | 2 ++ src/pages/api/revalidate.ts | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx index d18f4c3..6394d19 100644 --- a/src/pages/_app.tsx +++ b/src/pages/_app.tsx @@ -1,4 +1,3 @@ -import { GoogleAnalytics } from "@next/third-parties/google"; import { Noto_Sans_SC, Rubik } from "next/font/google"; import Layout from "@/components/layout"; @@ -6,8 +5,6 @@ import Layout from "@/components/layout"; import "@/styles/globals.css"; import type { AppProps } from "next/app"; -const isDisableTrack = process.env.ENABLE_TRACK === "false"; - const notoSC = Noto_Sans_SC({ weight: ["400", "500", "700"], subsets: ["latin"], @@ -36,7 +33,6 @@ export default function App({ Component, pageProps }: AppProps) { structuredData={pageProps.structuredData} > - {!isDisableTrack && } ); diff --git a/src/pages/_document.tsx b/src/pages/_document.tsx index c4e7a99..b53db9d 100644 --- a/src/pages/_document.tsx +++ b/src/pages/_document.tsx @@ -1,3 +1,4 @@ +import { GoogleAnalytics } from "@next/third-parties/google"; import { Html, Head, Main, NextScript } from "next/document"; import Script from "next/script"; @@ -57,6 +58,7 @@ export default function Document() { `} )} + {isEnableTrack && } ); diff --git a/src/pages/api/revalidate.ts b/src/pages/api/revalidate.ts index 40e658f..a2119f0 100644 --- a/src/pages/api/revalidate.ts +++ b/src/pages/api/revalidate.ts @@ -13,7 +13,7 @@ export default async function handler( } const payload = req.body; - const { pathname } = payload; + const { pathname } = JSON.parse(payload); if (typeof pathname !== "string") { return res.status(401).json({ message: "Invalid path." });