mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-27 07:52:24 +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
@@ -973,7 +973,7 @@
|
||||
<button id="storageClearBtn" type="button" class="btn-ghost focus-ring text-status-danger">
|
||||
Clear
|
||||
</button>
|
||||
<button id="storageCorsHelpBtn" type="button" class="btn-ghost focus-ring text-xs hidden">
|
||||
<button id="storageCorsHelpBtn" type="button" class="btn-ghost focus-ring text-xs">
|
||||
CORS setup help
|
||||
</button>
|
||||
</div>
|
||||
@@ -1875,10 +1875,8 @@
|
||||
|
||||
<div class="modal-body overflow-y-auto p-5 space-y-4 text-sm text-muted-strong">
|
||||
<p id="storageCorsModalIntro">
|
||||
Backblaze B2's web console CORS presets ("Share everything…") only allow
|
||||
<strong>downloads</strong>. Uploading from your browser uses an S3
|
||||
<code>PUT</code>/<code>POST</code>, which needs the <strong>custom</strong>
|
||||
rules below. Backblaze can only apply custom rules via its command-line tool.
|
||||
Uploading from your browser uses an S3 <code>PUT</code>/<code>POST</code>,
|
||||
which your bucket must allow via CORS.
|
||||
</p>
|
||||
|
||||
<div>
|
||||
@@ -1897,7 +1895,7 @@
|
||||
|
||||
<div>
|
||||
<div class="mb-1 flex items-center justify-between gap-2">
|
||||
<span class="font-medium text-text">Apply it (B2 command-line tool)</span>
|
||||
<span id="storageCorsCmdLabel" class="font-medium text-text">Apply it</span>
|
||||
<button id="storageCorsCopyCmdBtn" type="button" class="btn-ghost focus-ring text-xs">
|
||||
Copy command
|
||||
</button>
|
||||
@@ -1905,18 +1903,7 @@
|
||||
<pre class="card border border-default bg-surface-strong/40 p-3 overflow-x-auto text-xs leading-relaxed"><code id="storageCorsCli" class="whitespace-pre text-text"></code></pre>
|
||||
</div>
|
||||
|
||||
<ol class="list-decimal space-y-1 pl-5 text-xs text-muted">
|
||||
<li>Install Backblaze's <strong>B2 CLI</strong> (<code>pip install b2</code>) on your computer.</li>
|
||||
<li>Run the command above (it authorizes with your key, then sets the rules).</li>
|
||||
<li>Wait ~1 minute, then retry your upload in bitvid.</li>
|
||||
</ol>
|
||||
|
||||
<p class="text-xs text-muted">
|
||||
Prefer the web console? Its presets are fine for <strong>playback</strong> of
|
||||
already-uploaded files — only browser <strong>uploads</strong> need the custom
|
||||
rules above. (Tip: a B2 application key with the <code>writeBucketCors</code>
|
||||
capability lets bitvid set this for you automatically when you Save.)
|
||||
</p>
|
||||
<p id="storageCorsNotes" class="whitespace-pre-line text-xs text-muted"></p>
|
||||
</div>
|
||||
|
||||
<div class="modal-footer flex items-center justify-end gap-3 border-t border-border/60 p-4">
|
||||
|
||||
Reference in new issue
Block a user