Skip to main content

max / makenotwork

Fix S3 CORS for browser uploads, improve upload error visibility S3 bucket CORS was not configured — browser PUT requests to presigned URLs were silently blocked. Configured AllowedOrigins, AllowedMethods, AllowedHeaders on makenotwork-files bucket. Also improved JS error handling for non-JSON responses and made error display more prominent. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Author: Max J. <87768334+MaxJMath@users.noreply.github.com> · 2026-03-28 18:59 UTC
Commit: c78f642a0a287bd8c0a34ecec1115109a436f5f8
Parent: 00e8d2e
2 files changed, +12 insertions, -3 deletions
@@ -523,6 +523,9 @@
523 523 .upload-error-inline {
524 524 font-size: 0.85rem;
525 525 color: var(--danger, #c0392b);
526 + padding: 0.5rem 0.75rem;
527 + background: rgba(192, 57, 43, 0.08);
528 + border-radius: 4px;
526 529 }
527 530
528 531 /* Project Card Preview */
@@ -114,7 +114,10 @@
114 114 })
115 115 })
116 116 .then(function(res) {
117 - if (!res.ok) return res.json().then(function(d) { throw new Error(d.error || 'Failed to get upload URL'); });
117 + if (!res.ok) return res.text().then(function(body) {
118 + try { var d = JSON.parse(body); throw new Error(d.error || 'Failed to get upload URL'); }
119 + catch(e) { if (e.message && e.message !== body) throw e; throw new Error('Failed to get upload URL'); }
120 + });
118 121 return res.json();
119 122 })
120 123 .then(function(data) {
@@ -131,7 +134,10 @@
131 134 });
132 135 })
133 136 .then(function(res) {
134 - if (!res.ok) return res.json().then(function(d) { throw new Error(d.error || 'Failed to confirm upload'); });
137 + if (!res.ok) return res.text().then(function(body) {
138 + try { var d = JSON.parse(body); throw new Error(d.error || 'Failed to confirm upload'); }
139 + catch(e) { if (e.message && e.message !== body) throw e; throw new Error('Failed to confirm upload'); }
140 + });
135 141 return res.json();
136 142 })
137 143 .then(function(data) {
@@ -143,7 +149,7 @@
143 149 .catch(function(err) {
144 150 progressEl.classList.add('hidden');
145 151 chooseBtn.disabled = false;
146 - showError(err.message || 'Upload failed');
152 + showError(err.message || 'Upload failed. Please try again.');
147 153 });
148 154 }
149 155