feat(storage): apply CORS policy on organization S3 buckets at creation (#642) - #674
Open
fe51 wants to merge 1 commit into
Open
feat(storage): apply CORS policy on organization S3 buckets at creation (#642)#674fe51 wants to merge 1 commit into
fe51 wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #674 +/- ##
=======================================
Coverage 93.74% 93.75%
=======================================
Files 59 59
Lines 3147 3152 +5
=======================================
+ Hits 2950 2955 +5
Misses 197 197 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Member
Author
|
@MateoLostanlen all good to review ! test we randomly broken on a part of the code non related to the PR (triangulation). re-running it solve the failing test.. |
MateoLostanlen
approved these changes
Aug 12, 2026
MateoLostanlen
left a comment
Member
There was a problem hiding this comment.
LGTM. Have you already prepared the backfill script for the existing buckets?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #642
What and Why
Apply a CORS policy on organization S3 buckets at creation, so the platform's
"download all (ZIP)" and "download all + bounding boxes" buttons work.
These buttons use native
fetch()on presigned S3 URLs, which is subject to CORS —unlike the single-image download, which uses
<a download>and isn't. With no CORSconfig on the buckets, the browser blocked those cross-origin
fetch()es.How
S3Service.create_bucketnow applies a CORS rule right after creating the bucket:AllowedMethods:GET,HEAD(browser only reads images; uploads are server-side)AllowedOrigins: from the newS3_CORS_ORIGINSsettingAllowedHeaders:*ExposeHeaders:Content-Length,Content-TypeMaxAgeSeconds:3000Config / default
S3_CORS_ORIGINSis a comma-separated list of allowed frontend origins.Deployments must set it to the real frontend URLs (prod/preprod). The default
http://localhost:5173is a fail-closed fallback for local dev only — deliberatelynot
*, so a forgotten env var breaks visibly instead of silently allowing any origin.Existing buckets
This only applies to newly created buckets. I'll backfill the existing prod/preprod
buckets separately with a one-off script after merge.
Validation
put_bucket_corsis honored and served(confirmed the
Access-Control-Allow-Originheader is returned and the frontenddownload works end-to-end).