Fix upload / release mode build
This commit is contained in:
@@ -10,6 +10,7 @@ RUN go mod download
|
|||||||
COPY src/ .
|
COPY src/ .
|
||||||
|
|
||||||
ENV CGO_ENABLED=1
|
ENV CGO_ENABLED=1
|
||||||
|
ENV GIN_MODE=release
|
||||||
RUN go build -o server .
|
RUN go build -o server .
|
||||||
|
|
||||||
FROM alpine:latest
|
FROM alpine:latest
|
||||||
|
|||||||
@@ -289,21 +289,28 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
xhr.onload = () => {
|
xhr.onload = () => {
|
||||||
try {
|
// Check if the server actually returned a success status (200-299)
|
||||||
const data = JSON.parse(xhr.responseText);
|
if (xhr.status >= 200 && xhr.status < 300) {
|
||||||
if (data.error) throw new Error(data.error);
|
try {
|
||||||
|
const data = JSON.parse(xhr.responseText);
|
||||||
|
if (data.error) throw new Error(data.error);
|
||||||
|
|
||||||
document.getElementById('upload-ui').classList.add('hidden');
|
document.getElementById('upload-ui').classList.add('hidden');
|
||||||
document.getElementById('success-ui').classList.remove('hidden');
|
document.getElementById('success-ui').classList.remove('hidden');
|
||||||
|
|
||||||
const dlUrl = window.location.origin + data.download_url;
|
const dlUrl = window.location.origin + data.download_url;
|
||||||
const delUrl = `${window.location.origin}${data.delete_url}`;
|
const delUrl = `${window.location.origin}${data.delete_url}`;
|
||||||
|
|
||||||
document.getElementById('res-url').value = dlUrl;
|
document.getElementById('res-url').value = dlUrl;
|
||||||
document.getElementById('res-del').value = delUrl;
|
document.getElementById('res-del').value = delUrl;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
alert(err.message || "An error occurred");
|
console.error("JSON Parse Error. Server sent:", xhr.responseText);
|
||||||
location.reload();
|
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.`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user