AOSSIE-Org / AOSSIE-Org/EduAid

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

Aperta
#509 4 commenti 0 reazioni 0 assegnatari Vedi su GitHub
enhancement
Lingua principale
JavaScript
Stelle
171
Fork
425
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

### 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

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.