AOSSIE-Org / AOSSIE-Org/EduAid

[FEATURE]: Add configurable API base URL and backend connectivity indicator in eduaid_web

Ouverte
#509 4 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
enhancement
Langage dominant
JavaScript
Étoiles
171
Forks
425
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

### Feature and its Use Cases

In `eduaid_web`, API calls currently depend on localhost assumptions (commonly `5000`), while many local setups run backend on a different port (often `5001`). This frequently leads to `Failed to fetch` / CORS confusion even when backend is actually running.

### Proposed improvement

1. Centralize API endpoint configuration
- Use `REACT_APP_BASE_URL` as the primary source.
- Keep a clear fallback strategy for local development.
- Avoid hardcoded ambiguous behavior across pages.

2. Add backend connectivity indicator in UI
- Show a small non-intrusive banner/toast when backend is unreachable.
- Distinguish network/unreachable errors from normal API validation errors.
- Add a “Retry connection” action.

3. Improve error messaging for users
- Instead of generic `TypeError: Failed to fetch`, show actionable guidance:
- backend not running
- wrong configured API URL/port
- temporary network issue

### Why this helps

- Reduces onboarding/setup friction.
- Prevents repeated confusion with `5000` vs `5001` during local development.
- Improves user trust and debugging clarity.

### Proposed files (initial scope)

- `eduaid_web/src/utils/apiClient.js`
- `eduaid_web/src/App.js` (or a shared UI state holder)
- `eduaid_web/src/pages/Text_Input.jsx` (and any other API-heavy pages)

### Acceptance criteria

- API base URL is controlled from env config with documented fallback.
- User sees clear backend connection status when API is unreachable.
- Retry action is available and works.
- Existing successful API behavior remains unchanged.

### Additional Context

_No response_

### Code of Conduct

- [x] I have joined the [Discord server](https://discord.gg/hjUhu33uAn) and will post updates there
- [x] I have searched existing issues to avoid duplicates

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.