prasoonk1204/BreatheEasy

[Bug] AQI backend APIs return HTML instead of JSON

Open

#134 opened on Mar 3, 2026

 (0 comments) (0 reactions) (0 assignees)JavaScript (45 forks)auto 404
SWoC26bughelp wanted

Repository metrics

Stars
 (22 stars)
PR merge metrics
 (PR metrics pending)

Description

Describe the bug

The backend API endpoints for AQI data are returning HTML instead of the expected JSON responses. This causes the frontend to throw parsing errors. All requests to the following endpoints return HTML:

  • https://breathe-easy-1.vercel.app/api/aqi/current-location?
  • https://breathe-easy-1.vercel.app/api/aqi/top-cities
  • https://breathe-easy-1.vercel.app/api/aqi/city

Sample frontend error:

Error fetching AQI: SyntaxError: Unexpected token '<', "<!doctype "... is not valid JSON

Sample API response body:

<html lang="en">
  <head>...</head>
  <body>...</body>
</html>

This breaks air quality data display and prevents the app from loading AQI values.

Steps to Reproduce

  1. Make a GET request to any of the above API endpoints
  2. Observe that the response is HTML instead of JSON
  3. Frontend throws JSON parsing errors upon receiving this response

Expected behavior

All AQI API endpoints should respond with valid JSON objects as documented or expected by the frontend. If an error occurs, a JSON error response should be returned.

Additional context

  • Ensure that all API endpoints return JSON with appropriate headers (e.g., Content-Type: application/json).

Checklist

  • I have checked the existing issues to make sure this is not a duplicate.
  • I have read the contribution guidelines.

Contributor guide