import { type NextRequest, NextResponse } from "next/server";
import { env } from "~/env";
import type { ProxyFn } from "~/proxy";

export const TestRedirectProxy: ProxyFn = async (req: NextRequest) => {
	const { pathname } = req.nextUrl;

	if (!pathname.startsWith("/test")) {
		return;
	}

	if (env.NODE_ENV !== "development") {
		return new NextResponse("Unauthorized", { status: 401 });
	}

	return;
};
