fix: handle proxy timeout in SEO audit and return JSON on 404
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions

- Check content-type before parsing JSON in runAudit() to show
  helpful message when NPM proxy times out (returns HTML)
- Replace abort(404) with jsonify in audit trigger endpoint

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Maciej Pienczyn 2026-02-18 20:12:44 +01:00
parent 01f2a29f0b
commit 3d462d52f8
2 changed files with 5 additions and 1 deletions

View File

@ -348,7 +348,7 @@ def api_seo_audit_trigger():
- Error: Error message with status code
"""
if not is_audit_owner():
abort(404)
return jsonify({'success': False, 'error': 'Nie znaleziono'}), 404
# Check admin panel access
if not current_user.can_access_admin_panel():
return jsonify({

View File

@ -1966,6 +1966,10 @@ async function runAudit() {
body: JSON.stringify({ slug: companySlug })
});
const contentType = response.headers.get('content-type') || '';
if (!contentType.includes('application/json')) {
throw new Error('Serwer zwrócił nieprawidłową odpowiedź (timeout proxy?). Audyt mógł się zakończyć pomyślnie — odśwież stronę.');
}
const data = await response.json();
// Stop simulation, enrich with real data