π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Update worker origin handling for ente.com
Manav Rathi250f18299b1e
diff --git a/infra/workers/cast-albums/src/index.ts b/infra/workers/cast-albums/src/index.tsindex e493132299..c0dc02d3cf 100644--- a/infra/workers/cast-albums/src/index.ts+++ b/infra/workers/cast-albums/src/index.ts@@ -29,7 +29,12 @@ const handleOPTIONS = (request: Request) => {};const isAllowedOrigin = (origin: string | null) => {- const allowed = ["cast.ente.io", "cast.ente.sh", "localhost"];+ const allowed = [+ "cast.ente.com",+ "cast.ente.io",+ "cast.ente.sh",+ "localhost",+ ];if (!origin) return false;try {diff --git a/infra/workers/files/src/index.ts b/infra/workers/files/src/index.tsindex 6956e790d5..e3cf6d0e58 100644--- a/infra/workers/files/src/index.ts+++ b/infra/workers/files/src/index.ts@@ -35,6 +35,7 @@ const isAllowedOrigin = (origin: string | null) => {const hostname = url.hostname;return (origin == "ente://app" /* desktop app */ ||+ hostname.endsWith("ente.com") ||hostname.endsWith("ente.io") ||hostname.endsWith("ente.sh") ||hostname == "localhost"diff --git a/infra/workers/thumbnails/src/index.ts b/infra/workers/thumbnails/src/index.tsindex 5d0ed62ad1..9b79304c4a 100644--- a/infra/workers/thumbnails/src/index.ts+++ b/infra/workers/thumbnails/src/index.ts@@ -35,6 +35,7 @@ const isAllowedOrigin = (origin: string | null) => {const hostname = url.hostname;return (origin == "ente://app" /* desktop app */ ||+ hostname.endsWith("ente.com") ||hostname.endsWith("ente.io") ||hostname.endsWith("ente.sh") ||hostname == "localhost"diff --git a/infra/workers/uploader/src/index.ts b/infra/workers/uploader/src/index.tsindex 9918fe1ee4..af7572abed 100644--- a/infra/workers/uploader/src/index.ts+++ b/infra/workers/uploader/src/index.ts@@ -8,7 +8,7 @@ export default {async fetch(request: Request) {switch (request.method) {case "OPTIONS":- return handleOPTIONS(request);+ return handleOPTIONS();case "POST":return handlePOSTOrPUT(request);case "PUT":@@ -41,10 +41,8 @@ const isAllowedUploadURL = (uploadURL: string) => {}};-const handleOPTIONS = (request: Request) => {- const origin = request.headers.get("Origin");- if (!isAllowedOrigin(origin)) console.warn("Unknown origin", origin);- return new Response("", {+const handleOPTIONS = () =>+ new Response("", {headers: {"Access-Control-Allow-Origin": "*","Access-Control-Allow-Methods": "POST, PUT, OPTIONS",@@ -54,24 +52,6 @@ const handleOPTIONS = (request: Request) => {"Access-Control-Max-Age": "86400",},});-};--const isAllowedOrigin = (origin: string | null) => {- if (!origin) return false;- try {- const url = new URL(origin);- 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.- return false;- }-};const handlePOSTOrPUT = async (request: Request) => {const url = new URL(request.url);diff --git a/infra/workers/uploader/wrangler.toml b/infra/workers/uploader/wrangler.tomlindex 9a03d8c6d5..421a04b8d5 100644--- a/infra/workers/uploader/wrangler.toml+++ b/infra/workers/uploader/wrangler.toml@@ -1,6 +1,6 @@name = "uploader"main = "src/index.ts"-compatibility_date = "2024-06-14"+compatibility_date = "2026-04-23"routes = [{ pattern = "uploader.ente.io", custom_domain = true }]