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:
POST /api/github-token- Exchange GitHubcodeforaccess_token(server-side). RequiresGITHUB_CLIENT_IDandGITHUB_CLIENT_SECRETenv vars.GET /api/github-user- Get GitHub user info. UseAuthorization: token <access_token>or?token=<access_token>.GET /api/github-email- Get GitHub user emails. UseAuthorization: token <access_token>or?token=<access_token>.
Running locally
- Install dependencies (if not already):
cd api
npm install- Set environment variables (bash):
export GITHUB_CLIENT_ID=your_client_id
export GITHUB_CLIENT_SECRET=your_client_secret
export PORT=5200 # optional- Start the helper server:
npm start
# or for auto-reload during development:
npm run devNotes
- In development the frontend
webpackconfig already proxies/api/github-token,/api/github-user,/api/github-emailto GitHub. This helper lets you run a local server that performs the token exchange securely and returns JSON. - Do NOT put
GITHUB_CLIENT_SECRETinto frontend env vars (e.g.REACT_APP_*). Keep it server-side only.