Skip to content

fix(OUT-3888): route storage uploads through custom domain for C1 - #217

Merged
priosshrsth merged 6 commits into
mainfrom
anit/out-3888-client-home-banner-image-upload-not-working-for-c1
Jul 3, 2026
Merged

fix(OUT-3888): route storage uploads through custom domain for C1#217
priosshrsth merged 6 commits into
mainfrom
anit/out-3888-client-home-banner-image-upload-not-working-for-c1

Conversation

@priosshrsth

@priosshrsth priosshrsth commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

Changes

  • Rewrite Supabase signed upload URLs to the custom storage domain (NEXT_PUBLIC_SUPABASE_STORAGE_DOMAINclienthome-files.assembly.com) before the client-side PUT, so uploads hit an allowlisted host instead of *.supabase.co (fixes C1). Applied in uploadFileToSupabase, covering banners, editor images, and file drops.

Testing Criteria

2026-07-03.11-32-06.mov

Notes

  • Requires NEXT_PUBLIC_SUPABASE_STORAGE_DOMAIN set and clienthome-files.assembly.com fronting Supabase storage (OUT-3864 setup).

Impact & Surface Area of Change

  • Touches shared uploadFileToSupabase → all client upload paths. Downloads (/api/media/image proxy) unchanged.

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>
@linear-code

linear-code Bot commented Jul 3, 2026

Copy link
Copy Markdown

OUT-3888

@vercel

vercel Bot commented Jul 3, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
client-home-v3 Ready Ready Preview, Comment Jul 3, 2026 5:43am

Request Review

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@greptile-apps

greptile-apps Bot commented Jul 3, 2026

Copy link
Copy Markdown

Greptile Summary

This PR rewrites Supabase signed upload URLs to a custom domain (NEXT_PUBLIC_SUPABASE_STORAGE_URL) before the browser PUT, fixing uploads on C1 networks that block *.supabase.co. A new rewriteToStorageUrl helper activates only when the env var is present, preserving the signed token in the query string.

  • Adds src/config/public-env.ts with a Zod v4 schema validating the new NEXT_PUBLIC_SUPABASE_STORAGE_URL env var as an HTTPS URL using z.url({ protocol: /^https$/ }).nullish().
  • Rewrites the upload URL origin in uploadFileToSupabase via rewriteToStorageUrl, keeping path and query string intact so the signed token stays valid.
  • Cleans up media.service.ts by collapsing intermediate await/return pairs into return await.

Confidence Score: 5/5

Safe 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

Filename Overview
src/config/public-env.ts New module exposing a Zod-validated public env schema; z.url().nullish() rejects empty strings, which could cause a startup crash if the var is set to blank in a local .env.
src/features/editor/client.utils.ts Adds rewriteToStorageUrl helper that swaps origin on the signed URL while preserving path and query string; logic is correct and the no-op fallback when env var is unset is properly handled.
src/features/media/lib/media.service.ts Minor style cleanup — collapses await x; return x into return await x; no behavioral change.
.env.example Documents the new NEXT_PUBLIC_SUPABASE_STORAGE_URL env var with a clear inline comment and https:// example.
mise.toml Adds a dev task for the portless dev server; unrelated to the storage URL change.

Reviews (2): Last reviewed commit: "refactor(OUT-3888): drop storage domain ..." | Re-trigger Greptile

Comment thread src/features/editor/client.utils.ts
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>
@priosshrsth

Copy link
Copy Markdown
Collaborator Author

@greptileai re review the pr

@priosshrsth
priosshrsth merged commit 804423b into main Jul 3, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants