fix(r2): validate baseDomain to reject S3 API endpoints

Updated `r2Service.js` to detect if the user inputs an S3 API endpoint (e.g. `*.r2.cloudflarestorage.com`) as the Public Bucket URL. If detected, it prevents saving and displays a clear error message instructing the user to use the correct public domain (e.g. `*.r2.dev`). This prevents CORS errors and confusion caused by using the wrong endpoint type.
This commit is contained in:
google-labs-jules[bot] committed 2026-01-14 17:19:14 +00:00
1 parent fe1b6d0ae2
commit 0a79108c05
1 file changed
+10
+10
View File
@@ -220,6 +220,16 @@ class R2Service {
const secretAccessKey = String(formValues.secretAccessKey || "").trim();
const baseDomain = sanitizeBaseDomain(formValues.baseDomain || ""); // This is the Public Bucket URL
if (baseDomain.includes(".r2.cloudflarestorage.com")) {
if (!quiet) {
this.setCloudflareSettingsStatus(
"It looks like you entered the S3 API URL. Please use your Public Bucket URL (e.g. https://pub-xxx.r2.dev or your custom domain).",
"error"
);
}
return false;
}
if (!accountId || !accessKeyId || !secretAccessKey) {
if (!quiet) {
this.setCloudflareSettingsStatus(