mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-06 12:52:26 +00:00
[ui] #38: make the CORS setup helper provider-aware (R2 / B2 / Custom S3)
The first cut showed for Custom S3 too but always gave B2-only instructions (b2 CLI +
B2-native JSON), and was hidden for R2. Now the helper shows for all bucket providers
and tailors its content:
- Backblaze B2 -> B2-native rules + `b2 update-bucket --corsRules ...`
- Custom S3 -> standard S3 CORSConfiguration + `aws s3api put-bucket-cors
--endpoint-url <endpoint> ...`
- Cloudflare R2 -> standard S3 JSON + Cloudflare dashboard guidance (R2 -> bucket ->
Settings -> CORS Policy) and the AWS-CLI command vs the derived R2
endpoint.
Origins pre-filled from getCorsOrigins(); intro/command-label/notes set per provider;
copy buttons for both blocks. bitvid still auto-applies CORS on Save (R2/S3 via
ensureBucketCors) — this is the manual fallback when the key lacks CORS-write perms.
buildCorsHelpContent() switches on provider; modal text is now data-driven. Tests
extended to 10 (per-provider rules + command + a DOM provider-switch). Build + lint
clean; storage suites 40/40.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
1 parent
d7ad151698
commit
6006813b7e
5 files changed
+242
-115
No files matched your search
@@ -35,9 +35,12 @@ export class ProfileStorageController {
|
||||
this.storageR2Helper = null;
|
||||
this.storageB2Helper = null;
|
||||
this.storageS3Helper = null;
|
||||
// CORS setup helper modal (B2 / Custom S3) — owns its own DOM + behavior.
|
||||
// Provider-aware CORS setup helper modal — owns its own DOM + behavior.
|
||||
this.corsHelp = new StorageCorsHelp({
|
||||
getProvider: () => this.storageProviderInput?.value || "cloudflare_r2",
|
||||
getBucket: () => this.storageBucketInput?.value?.trim() || "",
|
||||
getRegion: () => this.storageRegionInput?.value?.trim() || "",
|
||||
getEndpoint: () => this.storageEndpointInput?.value?.trim() || "",
|
||||
});
|
||||
this.storageForcePathStyleInput = null;
|
||||
this.storageForcePathStyleLabel = null;
|
||||
@@ -447,7 +450,6 @@ export class ProfileStorageController {
|
||||
}
|
||||
}
|
||||
|
||||
// Region matters for B2 (drives the endpoint) and AWS-style S3; nudge the example.
|
||||
if (this.storageRegionInput && isB2) {
|
||||
this.storageRegionInput.placeholder = "us-west-004";
|
||||
} else if (this.storageRegionInput) {
|
||||
@@ -480,8 +482,7 @@ export class ProfileStorageController {
|
||||
);
|
||||
}
|
||||
|
||||
// Manual CORS helper is for S3-compatible providers (B2 / Custom S3), not R2.
|
||||
this.corsHelp.setVisible(!isR2);
|
||||
this.corsHelp.setVisible(true); // provider-aware; useful for all bucket providers
|
||||
}
|
||||
|
||||
getStorageUnlockFailureMessage(error) {
|
||||
@@ -814,8 +815,7 @@ export class ProfileStorageController {
|
||||
secretAccessKey,
|
||||
bucket,
|
||||
forcePathStyle,
|
||||
// Honor an explicit Public Access URL (custom domain / CDN); when blank,
|
||||
// validateS3Connection derives it from the endpoint + bucket.
|
||||
// Explicit Public Access URL (custom domain/CDN); blank → derived.
|
||||
publicBaseUrl: prefix || undefined,
|
||||
origins: getCorsOrigins(),
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user