fix: use assets.xtablo.com for org icon URLs instead of API proxy
Icons are stored in the web-assets R2 bucket which is already served via assets.xtablo.com, same as user avatars. No need to proxy through the API endpoint. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
ec056fbe6c
commit
bf66fc4000
4 changed files with 15 additions and 28 deletions
|
|
@ -420,7 +420,7 @@ export default function SettingsPage() {
|
|||
<div className="flex flex-wrap items-center gap-4">
|
||||
{organizationData?.organization?.logo_url ? (
|
||||
<img
|
||||
src={`${import.meta.env.VITE_API_URL}/api/v1/public/org-icons/${organizationData.organization.id}/icon-192.png`}
|
||||
src={`https://assets.xtablo.com/org-icons/${organizationData.organization.id}/icon-192.png`}
|
||||
alt="Organization logo"
|
||||
className="w-16 h-16 rounded-lg object-cover ring-2 ring-gray-100 dark:ring-gray-800 shrink-0"
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -26,17 +26,12 @@ describe("buildManifest", () => {
|
|||
expect(manifest.icons[0].src).toBe("/pwa-icons/pwa-192x192.png");
|
||||
});
|
||||
|
||||
it("returns org-specific icon URLs when orgId is provided", () => {
|
||||
const manifest = buildManifest(42, "https://api.example.com");
|
||||
it("returns org-specific icon URLs from assets.xtablo.com when orgId is provided", () => {
|
||||
const manifest = buildManifest(42);
|
||||
expect(manifest.name).toBe("XTablo");
|
||||
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[0].src).toBe("https://assets.xtablo.com/org-icons/42/icon-192.png");
|
||||
expect(manifest.icons[1].src).toBe("https://assets.xtablo.com/org-icons/42/icon-512.png");
|
||||
expect(manifest.icons[2].src).toBe("https://assets.xtablo.com/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");
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -25,7 +25,9 @@ interface WebAppManifest {
|
|||
icons: ManifestIcon[];
|
||||
}
|
||||
|
||||
export function buildManifest(orgId: number | null, apiUrl = ""): WebAppManifest {
|
||||
const ASSETS_BASE_URL = "https://assets.xtablo.com";
|
||||
|
||||
export function buildManifest(orgId: number | null): WebAppManifest {
|
||||
const base = {
|
||||
name: "XTablo",
|
||||
short_name: "XTablo",
|
||||
|
|
@ -41,9 +43,9 @@ export function buildManifest(orgId: number | null, apiUrl = ""): WebAppManifest
|
|||
return {
|
||||
...base,
|
||||
icons: [
|
||||
{ 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" },
|
||||
{ src: `${ASSETS_BASE_URL}/org-icons/${orgId}/icon-192.png`, sizes: "192x192", type: "image/png" },
|
||||
{ src: `${ASSETS_BASE_URL}/org-icons/${orgId}/icon-512.png`, sizes: "512x512", type: "image/png" },
|
||||
{ src: `${ASSETS_BASE_URL}/org-icons/${orgId}/icon-512-maskable.png`, sizes: "512x512", type: "image/png", purpose: "maskable" },
|
||||
],
|
||||
};
|
||||
}
|
||||
|
|
@ -58,18 +60,14 @@ export function buildManifest(orgId: number | null, apiUrl = ""): WebAppManifest
|
|||
};
|
||||
}
|
||||
|
||||
interface Env {
|
||||
API_URL?: string;
|
||||
}
|
||||
|
||||
export default {
|
||||
fetch(request: Request, env: Env) {
|
||||
fetch(request: Request) {
|
||||
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, env.API_URL || "");
|
||||
const manifest = buildManifest(orgId);
|
||||
|
||||
return new Response(JSON.stringify(manifest), {
|
||||
headers: {
|
||||
|
|
|
|||
|
|
@ -15,11 +15,5 @@ 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 }
|
||||
|
||||
[env.staging.vars]
|
||||
API_URL = "https://xablo-api-staging-636270553187.europe-west1.run.app"
|
||||
route = { pattern = "app-staging.xtablo.com", custom_domain = true }
|
||||
Loading…
Reference in a new issue