Allow albums.ente.io/sh

This commit is contained in:
Manav Rathi 2024-06-18 09:38:45 +05:30
parent d006f74cd4
commit 7566702569
No known key found for this signature in database

View File

@ -32,20 +32,18 @@ const handleOPTIONS = (request: Request) => {
};
const isAllowedOrigin = (origin: string | null) => {
const desktopApp = "ente://app";
const allowedHostnames = [
"web.ente.io",
"photos.ente.io",
"photos.ente.sh",
"localhost",
];
if (!origin) return false;
try {
const url = new URL(origin);
return origin == desktopApp || allowedHostnames.includes(url.hostname);
const hostname = url.hostname;
return (
origin == "ente://app" /* desktop app */ ||
hostname.endsWith("ente.io") ||
hostname.endsWith("ente.sh") ||
hostname == "localhost"
);
} catch {
// origin is likely an invalid URL
// `origin` is likely an invalid URL.
return false;
}
};