diff --git a/app/analytics.tsx b/app/analytics.tsx index 10c72e97..3861f62c 100644 --- a/app/analytics.tsx +++ b/app/analytics.tsx @@ -1,7 +1,11 @@ import Script from "next/script"; const Analytics = () => { - if (!process.env.NEXT_PUBLIC_UMAMI_WEBSITE_ID || process.env.NEXT_PUBLIC_VERCEL_ENV !== "production") { + if (process.env.NEXT_PUBLIC_VERCEL_ENV !== "production") { + return null; + } + + if (!process.env.NEXT_PUBLIC_UMAMI_WEBSITE_ID) { return null; } diff --git a/app/robots.ts b/app/robots.ts index 4834d00c..8ece4e26 100644 --- a/app/robots.ts +++ b/app/robots.ts @@ -7,8 +7,7 @@ const robots = (): MetadataRoute.Robots => ({ rules: [ { userAgent: "*", - // block access to staging sites - [process.env.NEXT_PUBLIC_VERCEL_ENV === "production" ? "allow" : "disallow"]: "/", + disallow: ["/_stream/", "/api/", "/stats/", "/tweets/", "/404", "/500"], }, ], sitemap: `${BASE_URL}/sitemap.xml`, diff --git a/app/sitemap.ts b/app/sitemap.ts index b8afa523..55c145f8 100644 --- a/app/sitemap.ts +++ b/app/sitemap.ts @@ -15,9 +15,6 @@ const sitemap = async (): Promise => { priority: 1.0, lastModified: new Date(process.env.RELEASE_DATE || Date.now()), // timestamp frozen when a new build is deployed }, - { url: `${BASE_URL}/stats` }, - { url: `${BASE_URL}/tweets` }, - { url: `${BASE_URL}/y2k` }, ]; // add each directory in the app folder as a route (excluding special routes) diff --git a/middleware.ts b/middleware.ts index 2ed8907a..838a1c0a 100644 --- a/middleware.ts +++ b/middleware.ts @@ -1,5 +1,5 @@ import { NextResponse } from "next/server"; -import type { NextRequest } from "next/server"; +import type { NextRequest, MiddlewareConfig } from "next/server"; // assign "short codes" to approved reverse proxy destinations. for example: // ["abc", "https://jakejarvis.github.io"] => /_stream/abc/123.html -> https://jakejarvis.github.io/123.html @@ -67,7 +67,7 @@ export const middleware = (request: NextRequest) => { }); }; -export const config = { +export const config: MiddlewareConfig = { // save compute time by skipping middleware for static and metadata files matcher: [ "/((?!_next/static|_next/image|_vercel|api|static|\\.well-known|favicon.ico|icon.png|apple-icon.png|sitemap.xml|robots.txt|manifest.webmanifest|feed.xml|feed.atom).*)",