fix: configure self-hosted S3 CORS for presigned uploads (#3379) - #3811
Open
ansaftab-1 wants to merge 1 commit into
Open
ansaftab-1 wants to merge 1 commit into
ansaftab-1 wants to merge 1 commit into
Conversation
ansaftab-1
requested review from
ProgrammerIn-wonderland,
Salazareo,
jelveh and
jfcastro92
as code owners
September 6, 2026 23:01
|
|
Member
|
hi @ansaftab-1 could you please sign CLA |
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.
Problem
In self-hosted Puter deployments, browser file uploads fail with a CORS policy error when sending
PUTrequests to S3 presigned URLs on RustFS (s3.<domain>). The browser issues an HTTPOPTIONSpreflight request prior to the upload, but because the bucket was created without a bucket-level CORS policy, RustFS does not return the requiredAccess-Control-Allow-*headers.Fixes #3379
Solution
Automated Bucket CORS Policy (
docker-compose.yml):s3-initservice to passPUTER_DOMAINandPUTER_PROTOCOL.s3-initwrites and applies a bucket-level CORS configuration allowing origins for${PUTER_PROTOCOL}://${PUTER_DOMAIN}and its subdomains (api,app,site,dev,host).AllowedMethods: ["GET", "HEAD", "PUT", "POST", "DELETE"],AllowedHeaders: ["*"],ExposeHeaders: ["ETag", "x-amz-request-id"], andMaxAgeSeconds: 3600.aws --endpoint-url "$endpoint" s3api put-bucket-cors.Idempotent Initialization:
head-bucketsucceeds),s3-initdoes not exit early; it proceeds to apply/update the CORS policy so existing installations receive the fix without data loss.Installer Support (
install.sh&install.ps1):install.shandinstall.ps1to writePUTER_DOMAINandPUTER_PROTOCOLto.env.install.ps1to accept-PuterProtocolparameter and dynamically configureprotocolandpublicEndpointinconfig.json.Documentation:
PUTER_DOMAINandPUTER_PROTOCOLindoc/self-hosting.mdand.env.example, including HTTPS setup instructions.Testing:
tools/test-s3-cors.mjs) validating default HTTP domain origins, custom HTTPS domain origins, allowed methods/headers, absence of wildcard origins, simulated browserOPTIONSpreflights, idempotency logic, and installer consistency.Tests Run
node tools/test-s3-cors.mjs: 20/20 tests passed.git diff --check: Passed with 0 whitespace errors.sh -n install.sh: Passed with exit code 0.install.ps1: Passed with 0 errors.docker-compose.yml: Passed with exit code 0.