server/utils/response.ts

21 lines
473 B
TypeScript
Raw Normal View History

import { config } from "~/packages/config-manager";
export type Json =
| string
| number
| boolean
| null
| undefined
| Json[]
| { [key: string]: Json };
2024-05-16 05:07:34 +02:00
export const proxyUrl = (url: string | null = null) => {
const urlAsBase64Url = Buffer.from(url || "").toString("base64url");
return url
? new URL(
`/media/proxy/${urlAsBase64Url}`,
config.http.base_url,
).toString()
: url;
};