fix: proxy

This commit is contained in:
Ou 2024-11-01 20:14:11 +08:00
parent 9fb02f5fa7
commit 353ec94518
2 changed files with 3 additions and 3 deletions

View File

@ -1,7 +1,7 @@
export default defineEventHandler(async (event) => {
const img = getQuery(event).url
const { url: img, type = "encodeURIComponent" } = getQuery(event)
if (img) {
const url = decodeBase64URL(img as string)
const url = type === "encodeURIComponent" ? encodeURIComponent(img as string) : decodeBase64URL(img as string)
return sendProxy(event, url, {
headers: {
"Access-Control-Allow-Origin": "*",

View File

@ -1,4 +1,4 @@
export function proxyPicture(url: string, type: "encodeURIComponent" | "encodeBase64URL" = "encodeURIComponent") {
const encoded = type === "encodeBase64URL" ? encodeBase64URL(url) : encodeURIComponent(url)
return `/api/proxy/img.png?url=${encoded}`
return `/api/proxy/img.png?type=${type}&url=${encoded}`
}