Fix production auth by proxying /api to backend in remote builds.
Remote frontend nginx now forwards API requests to Django so login and registration work when the host proxy only routes to port 8080. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,6 +1,14 @@
|
||||
export function formatApiErrorData(data) {
|
||||
if (!data) return ''
|
||||
if (typeof data === 'string' && data.trim()) return data.trim()
|
||||
if (typeof data === 'string' && data.trim()) {
|
||||
const text = data.trim()
|
||||
if (text.startsWith('<') && text.includes('</html>')) {
|
||||
const title = text.match(/<title>([^<]+)<\/title>/i)?.[1]?.trim()
|
||||
if (title) return title
|
||||
return 'Сервер вернул HTML вместо JSON. Проверьте проксирование /api на backend.'
|
||||
}
|
||||
return text
|
||||
}
|
||||
if (typeof data?.detail === 'string' && data.detail.trim()) return data.detail.trim()
|
||||
if (Array.isArray(data?.non_field_errors) && data.non_field_errors.length) {
|
||||
return data.non_field_errors.join('; ')
|
||||
|
||||
Reference in New Issue
Block a user