AOSSIE-Org / AOSSIE-Org/EduAid

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

Offen
#509 4 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
enhancement
Vorherrschende Sprache
JavaScript
Sterne
171
Forks
425
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.