[Update] Update various configuration files, ESLint config, Prettier config, and added new files including a CHANGELOG.md.

This commit is contained in:
mbaharip
2025-01-01 09:02:47 +07:00
parent b8ad5ad890
commit fdb55cccf5
139 changed files with 5770 additions and 12296 deletions
+31
View File
@@ -0,0 +1,31 @@
import { type NextRequest, NextResponse } from "next/server";
export async function middleware(req: NextRequest) {
const response = NextResponse.next();
const pathname = req.nextUrl.pathname;
// Skip the middleware if the pathname is the root
if (pathname === "/") return response;
// Get search params
const searchParams = new URLSearchParams(req.nextUrl.search);
// Check if it's has raw query
const hasRawQuery = searchParams.get("raw") === "1";
// If it's has raw query, redirect it to `/api/raw?url=${pathname}`
if (hasRawQuery) {
const rawUrl = `/api/raw?url=${encodeURIComponent(pathname)}`;
return new NextResponse(null, {
status: 307,
headers: {
Location: new URL(rawUrl, req.nextUrl.origin).toString(),
},
});
}
return response;
}
export const config = {
matcher: ["/((?!api|_next/static|_next/image|favicon.ico|sitemap.xml|robots.txt).*)"],
};