newsnow/server/api/proxy/img.png.ts

15 lines
535 B
TypeScript
Raw Normal View History

2024-10-25 18:00:37 +08:00
export default defineEventHandler(async (event) => {
2024-11-01 20:14:11 +08:00
const { url: img, type = "encodeURIComponent" } = getQuery(event)
2024-10-25 18:00:37 +08:00
if (img) {
2024-11-01 20:14:11 +08:00
const url = type === "encodeURIComponent" ? encodeURIComponent(img as string) : decodeBase64URL(img as string)
2024-10-25 18:00:37 +08:00
return sendProxy(event, url, {
headers: {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Credentials": "*",
"Access-Control-Allow-Methods": "GET, HEAD, POST, PUT, OPTIONS",
"Access-Control-Allow-Headers": "*",
},
})
}
})