mirror of
https://github.com/ourongxing/newsnow.git
synced 2025-01-18 18:59:15 +08:00
fix: proxy
This commit is contained in:
parent
9fb02f5fa7
commit
353ec94518
@ -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": "*",
|
||||
|
@ -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}`
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user