Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
225 changes: 165 additions & 60 deletions web/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"format": "prettier --write ."
},
"dependencies": {
"glob": "^13.0.3",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
Expand Down
16 changes: 14 additions & 2 deletions web/src/components/UploadForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,10 @@ export default function UploadForm({ file, onFileChange }) {
fd.append('format', format)
fd.append('quality', String(quality))

// API Base URL (for dev mode)
// API Base URL
const apiBase =
import.meta.env && import.meta.env.DEV ? 'http://localhost:8080' : ''
import.meta.env.VITE_API_URL ||
(import.meta.env.DEV ? 'http://localhost:8080' : '')

setLoading(true)
try {
Expand All @@ -244,6 +245,17 @@ export default function UploadForm({ file, onFileChange }) {
method: 'POST',
body: fd,
})

// Check if the response is JSON
const contentType = res.headers.get('content-type')
if (!contentType || !contentType.includes('application/json')) {
const text = await res.text()
console.error('Non-JSON response received:', text)
throw new Error(
'Server returned an unexpected response format. Please ensure the backend is running and accessible.'
)
}

const data = await res.json()

if (!res.ok) {
Expand Down
Loading