feat(api): 🔒 Make all media be proxied through an internal proxy

This commit is contained in:
Jesse Wierzbinski 2024-05-04 19:13:23 -10:00
parent 9547cd097a
commit ead34b818f
No known key found for this signature in database
8 changed files with 54 additions and 18 deletions

View file

@ -1,3 +1,5 @@
import { config } from "~packages/config-manager";
export const response = (
data: BodyInit | null = null,
status = 200,
@ -69,3 +71,12 @@ export const redirect = (url: string | URL, status = 302) => {
Location: url.toString(),
});
};
export const proxyUrl = (url: string | null) => {
return url
? new URL(
`/media/proxy?url=${encodeURIComponent(url)}`,
config.http.base_url,
).toString()
: url;
};

View file

@ -1,5 +1,5 @@
import xss, { type IFilterXSSOptions } from "xss";
import { stringifyEntitiesLight } from "stringify-entities";
import xss, { type IFilterXSSOptions } from "xss";
export const sanitizedHtmlStrip = (html: string) => {
return sanitizeHtml(html, {