diff --git a/apps/main/src/pages/settings.tsx b/apps/main/src/pages/settings.tsx
index 248fd23..3c9d07c 100644
--- a/apps/main/src/pages/settings.tsx
+++ b/apps/main/src/pages/settings.tsx
@@ -420,7 +420,7 @@ export default function SettingsPage() {
{organizationData?.organization?.logo_url ? (

diff --git a/apps/main/worker/index.test.ts b/apps/main/worker/index.test.ts
index 75f05e9..1eebd61 100644
--- a/apps/main/worker/index.test.ts
+++ b/apps/main/worker/index.test.ts
@@ -27,11 +27,16 @@ describe("buildManifest", () => {
});
it("returns org-specific icon URLs when orgId is provided", () => {
- const manifest = buildManifest(42);
+ const manifest = buildManifest(42, "https://api.example.com");
expect(manifest.name).toBe("XTablo");
- expect(manifest.icons[0].src).toBe("/api/v1/public/org-icons/42/icon-192.png");
- expect(manifest.icons[1].src).toBe("/api/v1/public/org-icons/42/icon-512.png");
- expect(manifest.icons[2].src).toBe("/api/v1/public/org-icons/42/icon-512-maskable.png");
+ expect(manifest.icons[0].src).toBe("https://api.example.com/api/v1/public/org-icons/42/icon-192.png");
+ expect(manifest.icons[1].src).toBe("https://api.example.com/api/v1/public/org-icons/42/icon-512.png");
+ expect(manifest.icons[2].src).toBe("https://api.example.com/api/v1/public/org-icons/42/icon-512-maskable.png");
expect(manifest.icons[2].purpose).toBe("maskable");
});
+
+ it("uses empty string as apiUrl fallback", () => {
+ const manifest = buildManifest(42);
+ expect(manifest.icons[0].src).toBe("/api/v1/public/org-icons/42/icon-192.png");
+ });
});
diff --git a/apps/main/worker/index.ts b/apps/main/worker/index.ts
index b841e1f..32ccf0d 100644
--- a/apps/main/worker/index.ts
+++ b/apps/main/worker/index.ts
@@ -25,7 +25,7 @@ interface WebAppManifest {
icons: ManifestIcon[];
}
-export function buildManifest(orgId: number | null): WebAppManifest {
+export function buildManifest(orgId: number | null, apiUrl = ""): WebAppManifest {
const base = {
name: "XTablo",
short_name: "XTablo",
@@ -41,9 +41,9 @@ export function buildManifest(orgId: number | null): WebAppManifest {
return {
...base,
icons: [
- { src: `/api/v1/public/org-icons/${orgId}/icon-192.png`, sizes: "192x192", type: "image/png" },
- { src: `/api/v1/public/org-icons/${orgId}/icon-512.png`, sizes: "512x512", type: "image/png" },
- { src: `/api/v1/public/org-icons/${orgId}/icon-512-maskable.png`, sizes: "512x512", type: "image/png", purpose: "maskable" },
+ { src: `${apiUrl}/api/v1/public/org-icons/${orgId}/icon-192.png`, sizes: "192x192", type: "image/png" },
+ { src: `${apiUrl}/api/v1/public/org-icons/${orgId}/icon-512.png`, sizes: "512x512", type: "image/png" },
+ { src: `${apiUrl}/api/v1/public/org-icons/${orgId}/icon-512-maskable.png`, sizes: "512x512", type: "image/png", purpose: "maskable" },
],
};
}
@@ -58,14 +58,18 @@ export function buildManifest(orgId: number | null): WebAppManifest {
};
}
+interface Env {
+ API_URL?: string;
+}
+
export default {
- fetch(request: Request) {
+ fetch(request: Request, env: Env) {
const url = new URL(request.url);
if (url.pathname === "/manifest.webmanifest") {
const cookieHeader = request.headers.get("cookie");
const orgId = parseOrgIdFromCookie(cookieHeader);
- const manifest = buildManifest(orgId);
+ const manifest = buildManifest(orgId, env.API_URL || "");
return new Response(JSON.stringify(manifest), {
headers: {
diff --git a/apps/main/wrangler.toml b/apps/main/wrangler.toml
index 47c3ef1..b56b580 100644
--- a/apps/main/wrangler.toml
+++ b/apps/main/wrangler.toml
@@ -15,5 +15,11 @@ PYTHON_VERSION = "3.11.5"
[env.production]
route = { pattern = "app.xtablo.com", custom_domain = true }
+[env.production.vars]
+API_URL = "https://xablo-api-636270553187.europe-west1.run.app"
+
[env.staging]
-route = { pattern = "app-staging.xtablo.com", custom_domain = true }
\ No newline at end of file
+route = { pattern = "app-staging.xtablo.com", custom_domain = true }
+
+[env.staging.vars]
+API_URL = "https://xablo-api-staging-636270553187.europe-west1.run.app"
\ No newline at end of file