Skip to content

Commit 5bae930

Browse files
committed
feat: fix github login
1 parent 1e0cb7f commit 5bae930

File tree

6 files changed

+721
-207
lines changed

6 files changed

+721
-207
lines changed

api/README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# pro-react-admin API helper
2+
3+
This `api/` folder contains a small Express helper used during local development. It exposes a few endpoints used by the frontend for GitHub OAuth in local/dev mode:
4+
5+
- `POST /api/github-token` - Exchange GitHub `code` for `access_token` (server-side). Requires `GITHUB_CLIENT_ID` and `GITHUB_CLIENT_SECRET` env vars.
6+
- `GET /api/github-user` - Get GitHub user info. Use `Authorization: token <access_token>` or `?token=<access_token>`.
7+
- `GET /api/github-email` - Get GitHub user emails. Use `Authorization: token <access_token>` or `?token=<access_token>`.
8+
9+
Running locally
10+
11+
1. Install dependencies (if not already):
12+
13+
```bash
14+
cd api
15+
npm install
16+
```
17+
18+
2. Set environment variables (bash):
19+
20+
```bash
21+
export GITHUB_CLIENT_ID=your_client_id
22+
export GITHUB_CLIENT_SECRET=your_client_secret
23+
export PORT=5200 # optional
24+
```
25+
26+
3. Start the helper server:
27+
28+
```bash
29+
npm start
30+
# or for auto-reload during development:
31+
npm run dev
32+
```
33+
34+
Notes
35+
36+
- In development the frontend `webpack` config already proxies `/api/github-token`, `/api/github-user`, `/api/github-email` to GitHub. This helper lets you run a local server that performs the token exchange securely and returns JSON.
37+
- Do NOT put `GITHUB_CLIENT_SECRET` into frontend env vars (e.g. `REACT_APP_*`). Keep it server-side only.

0 commit comments

Comments
 (0)