feat: add bypass api

This commit is contained in:
DIYgod 2023-08-12 12:24:18 +01:00
parent 478b8e496b
commit 6563a9c273
No known key found for this signature in database
1 changed files with 16 additions and 0 deletions

View File

@ -0,0 +1,16 @@
// This API is used to bypass the restriction that the Cloudflare Image Resizing service's onerror=redirect can only be used in current domain
import { redirect } from "next/navigation"
import { type NextRequest, NextResponse } from "next/server"
import { getQuery } from "~/lib/server-helper"
export const runtime = "edge"
export const GET = async (req: NextRequest) => {
const query = getQuery(req)
if (query.url) {
redirect(query.url)
} else {
return NextResponse.json({ error: "Missing url" })
}
}