Fix upload / release mode build

This commit is contained in:
2026-02-26 21:04:33 +01:00
parent a0a70c47d9
commit 1a0d8ec78b
2 changed files with 20 additions and 12 deletions

View File

@@ -10,6 +10,7 @@ RUN go mod download
COPY src/ .
ENV CGO_ENABLED=1
ENV GIN_MODE=release
RUN go build -o server .
FROM alpine:latest

View File

@@ -289,21 +289,28 @@
};
xhr.onload = () => {
try {
const data = JSON.parse(xhr.responseText);
if (data.error) throw new Error(data.error);
// Check if the server actually returned a success status (200-299)
if (xhr.status >= 200 && xhr.status < 300) {
try {
const data = JSON.parse(xhr.responseText);
if (data.error) throw new Error(data.error);
document.getElementById('upload-ui').classList.add('hidden');
document.getElementById('success-ui').classList.remove('hidden');
document.getElementById('upload-ui').classList.add('hidden');
document.getElementById('success-ui').classList.remove('hidden');
const dlUrl = window.location.origin + data.download_url;
const delUrl = `${window.location.origin}${data.delete_url}`;
const dlUrl = window.location.origin + data.download_url;
const delUrl = `${window.location.origin}${data.delete_url}`;
document.getElementById('res-url').value = dlUrl;
document.getElementById('res-del').value = delUrl;
} catch (err) {
alert(err.message || "An error occurred");
location.reload();
document.getElementById('res-url').value = dlUrl;
document.getElementById('res-del').value = delUrl;
} catch (err) {
console.error("JSON Parse Error. Server sent:", xhr.responseText);
alert("Server returned an invalid response. Check console (F12) for details.");
}
} else {
// If the server sent a 404, 413 (File too large), or 500 error
console.error("Server Error:", xhr.status, xhr.responseText);
alert(`Upload failed with status ${xhr.status}. Check console.`);
}
};