newsnow/server/api/proxy.ts
2024-10-25 18:00:37 +08:00

15 lines
436 B
TypeScript

export default defineEventHandler(async (event) => {
const img = getQuery(event).img
if (img) {
const url = decodeURIComponent(img as string)
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": "*",
},
})
}
})