AOSSIE-Org / AOSSIE-Org/EduAid

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

オープン
#509 コメント 4 件 リアクション 0 件 担当者 0 名 GitHub で見る
enhancement
主要言語
JavaScript
スター
171
フォーク
425
PR マージ指標
30日以内にマージされた PR はありません

説明

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

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。