Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,15 @@ type OgMetadata = {
};

// Constants
const BASE_URL = "https://policyengine.org";
const BASE_URL = "https://www.policyengine.org";

// Paths that Vercel rewrites to external apps with their own SSR + meta tags.
// Let all user agents (including bots) pass through to the actual app.
const REWRITE_PREFIXES = [
"/us/keep-your-pay-act",
"/us/taxsim",
"/us/api",
];

export const CRAWLER_USER_AGENTS = [
"facebookexternalhit",
Expand Down Expand Up @@ -87,7 +95,7 @@ const DEFAULT_OG = {
title: "PolicyEngine",
description:
"Free, open-source tools to understand tax and benefit policies. Calculate your taxes and benefits, or analyze policy reforms.",
image: "https://policyengine.org/assets/logos/policyengine/teal.png",
image: "https://www.policyengine.org/assets/logos/policyengine/teal.png",
};

const STATIC_PAGES: Record<string, { title: string; description: string }> = {
Expand Down Expand Up @@ -414,6 +422,13 @@ export default async function middleware(request: Request) {
return;
}

// Let rewritten tool paths pass through — the external apps have their own
// SSR, meta tags, OG images, and JSON-LD, so the middleware stub would be
// strictly less content than what the actual app serves.
if (REWRITE_PREFIXES.some((p) => url.pathname.startsWith(p))) {
return;
}

// Let static files (sitemap, robots, etc.) pass through to Vercel's file serving
if (url.pathname === "/sitemap.xml" || url.pathname === "/robots.txt") {
return;
Expand Down
Loading