fix: add better error logging for deploy API

This commit is contained in:
F4ilji
2026-07-02 16:55:43 +05:00
parent 2b5b4ee48f
commit e0cb9642cd
+20 -4
View File
@@ -32,7 +32,14 @@ const fetchStatus = async () => {
credentials: 'same-origin',
headers,
})
status.value = await response.json()
const text = await response.text()
try {
status.value = JSON.parse(text)
} catch {
console.error('Status response is not JSON:', text.substring(0, 200))
return
}
if (!status.value.running && pollingInterval) {
clearInterval(pollingInterval)
@@ -50,15 +57,24 @@ const startDeploy = async () => {
credentials: 'same-origin',
headers,
})
const data = await response.json()
const text = await response.text()
console.log('Deploy response:', response.status, text)
let data
try {
data = JSON.parse(text)
} catch {
alert('Server returned HTML instead of JSON. Check console.')
return
}
if (response.ok) {
startPolling()
} else {
alert(data.error || 'Failed to start deploy:' + data.error)
alert(data.error || 'Failed to start deploy')
}
} catch (error) {
alert('Failed to start deploy:' + error)
alert('Failed to start deploy: ' + error.message)
}
}