AOSSIE-Org / AOSSIE-Org/EduAid

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

Đang mở
#509 4 bình luận 0 reaction 0 người được giao Xem trên GitHub
enhancement
Ngôn ngữ chính
JavaScript
Star
171
Fork
425
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.