fix(OUT-3888): route storage uploads through custom domain for C1 - #217
Conversation
Signed upload URLs from Supabase point at the raw *.supabase.co host, and the browser PUTs file bytes directly to it. Networks that only allowlist assembly.com (C1) block that request, so banner/editor image and file uploads fail with CORS/network errors in the console. Rewrite the signed upload URL origin to NEXT_PUBLIC_SUPABASE_STORAGE_DOMAIN (clienthome-files.assembly.com) before the client-side PUT, preserving the path and signed token. All client uploads funnel through uploadFileToSupabase so banners, editor images, and file drops are covered. Falls back to the original URL when the env var is unset. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Greptile SummaryThis PR rewrites Supabase signed upload URLs to a custom domain (
Confidence Score: 5/5Safe to merge — the URL rewriting is correct, the no-op fallback for non-C1 environments is properly gated, and the signed token is preserved through the origin swap. The core logic in rewriteToStorageUrl correctly replaces only the origin while keeping path and query string intact, and the feature is entirely inert when the env var is unset. The one note is that z.url().nullish() rejects an empty string, which could cause a startup crash if the var is accidentally set to blank, but this is a minor resilience concern rather than a defect in the intended code path. The Zod schema in src/config/public-env.ts warrants a quick look for the empty-string edge case. Important Files Changed
Reviews (2): Last reviewed commit: "refactor(OUT-3888): drop storage domain ..." | Re-trigger Greptile |
Accept NEXT_PUBLIC_SUPABASE_STORAGE_DOMAIN as either a full URL or a bare hostname, and fall back to the original signed URL if parsing fails so a misconfigured value never breaks uploads. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add NEXT_PUBLIC_SUPABASE_STORAGE_DOMAIN to the env schema and read it through the validated env object instead of process.env directly. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
env.ts is server-only, so client code cannot import it. Add public-env.ts (NEXT_PUBLIC_* only, not server-only) and use it in the upload helper. Rename the var to NEXT_PUBLIC_SUPABASE_STORAGE_URL, validated as a full https URL, and drop the bare-hostname/try-catch handling. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The storage URL now lives in the client-safe public-env module, so remove NEXT_PUBLIC_SUPABASE_STORAGE_DOMAIN and the env named export from the server env schema. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
@greptileai re review the pr |
Changes
NEXT_PUBLIC_SUPABASE_STORAGE_DOMAIN→clienthome-files.assembly.com) before the client-sidePUT, so uploads hit an allowlisted host instead of*.supabase.co(fixes C1). Applied inuploadFileToSupabase, covering banners, editor images, and file drops.Testing Criteria
2026-07-03.11-32-06.mov
Notes
NEXT_PUBLIC_SUPABASE_STORAGE_DOMAINset andclienthome-files.assembly.comfronting Supabase storage (OUT-3864 setup).Impact & Surface Area of Change
uploadFileToSupabase→ all client upload paths. Downloads (/api/media/imageproxy) unchanged.