diff --git a/js/app.js b/js/app.js index 4ad3fff..961ebc8 100644 --- a/js/app.js +++ b/js/app.js @@ -357,21 +357,21 @@ async function disablePwaForAuthGate() { async function uploadCoverImage(file) { try { - const formData = new FormData(); - formData.append('file', file); - - const response = await fetch('/upload', { - method: 'POST', - body: formData, + const response = await fetch(`https://worker.uploads.monochrome.qzz.io/${file.name}`, { + method: 'PUT', + headers: { + 'x-api-key': 'if_youre_reading_this_fuck_off', + 'Content-Type': file.type || 'application/octet-stream', + }, + body: file, }); if (!response.ok) { - const error = await response.json(); - throw new Error(error.error || `Upload failed: ${response.status}`); + if (response.status === 413) throw new Error('File exceeds 10MB'); + throw new Error(`Upload failed: ${response.status}`); } - const data = await response.json(); - return data.url; + return `https://images.monochrome.qzz.io/${await response.text()}`; } catch (error) { console.error('Cover upload error:', error); throw error; diff --git a/js/profile.js b/js/profile.js index 2910c53..6d9159d 100644 --- a/js/profile.js +++ b/js/profile.js @@ -37,15 +37,22 @@ let currentFavoriteAlbums = []; const api = new MusicAPI(apiSettings); async function uploadImage(file) { - const formData = new FormData(); - formData.append('file', file); - try { - const response = await fetch('/upload', { method: 'POST', body: formData }); - if (!response.ok) throw new Error(`Upload failed: ${response.status}`); - const data = await response.json(); - if (!data.success) throw new Error(data.error || 'Upload failed'); - return data.url; + const response = await fetch(`https://worker.uploads.monochrome.qzz.io/${file.name}`, { + method: 'PUT', + headers: { + 'x-api-key': 'if_youre_reading_this_fuck_off', + 'Content-Type': file.type || 'application/octet-stream', + }, + body: file, + }); + + if (!response.ok) { + if (response.status === 413) throw new Error('File exceeds 10MB'); + throw new Error(`Upload failed: ${response.status}`); + } + + return `https://images.monochrome.qzz.io/${await response.text()}`; } catch (error) { console.error('Upload error:', error); throw error;