Skip to content

Commit a23e8f2

Browse files
committed
Fix GH redirect URI
1 parent f653f2d commit a23e8f2

File tree

4 files changed

+60
-5
lines changed

4 files changed

+60
-5
lines changed

.github/workflows/docker-build.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ jobs:
8484
build-args: |
8585
GH_CLIENT_ID=${{ secrets.GH_CLIENT_ID }}
8686
GH_CLIENT_SECRET=${{ secrets.GH_CLIENT_SECRET }}
87-
GITHUB_REDIRECT_URI=${{ vars.GITHUB_REDIRECT_URI }}
87+
GH_REDIRECT_URI=${{ vars.GH_REDIRECT_URI }}
8888
CORS_ORIGIN=${{ vars.CORS_ORIGIN }}
8989
9090
- name: 📝 Generate image summary

docs/GITHUB_ACTIONS_ENV.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# GitHub Actions Environment Configuration
2+
3+
## Problem Solved
4+
The OAuth redirect was going to `localhost:3000` because the server wasn't receiving the correct `GH_REDIRECT_URI` environment variable.
5+
6+
## Root Cause
7+
Environment variable name mismatch:
8+
- Server code expects: `GH_REDIRECT_URI`
9+
- You were using: `GITHUB_REDIRECT_URI`
10+
11+
## Required GitHub Configuration
12+
13+
### Secrets (Encrypted)
14+
```
15+
GH_CLIENT_ID=Ov23liWFBY2V44492XIc
16+
GH_CLIENT_SECRET=dfbbb128f1f780f9b92196752e7017c7e1f8cc51
17+
```
18+
19+
### Variables (Plain Text)
20+
```
21+
NEXT_PUBLIC_API_URL=https://tracker-api.nesohq.org
22+
GH_REDIRECT_URI=https://tracker.nesohq.org/auth/callback
23+
CORS_ORIGIN=https://tracker.nesohq.org
24+
```
25+
26+
## Action Required
27+
28+
⚠️ **You need to rename your GitHub Variable:**
29+
30+
1. Go to: Settings → Secrets and variables → Actions → Variables
31+
2. Delete the variable named `GITHUB_REDIRECT_URI`
32+
3. Create a new variable named `GH_REDIRECT_URI` with value: `https://tracker.nesohq.org/auth/callback`
33+
34+
## Files Updated
35+
-`server/.env` - Fixed variable name
36+
-`server/.env.example` - Updated example
37+
-`server/Dockerfile` - Updated build arg name
38+
-`.github/workflows/docker-build.yaml` - Updated to use correct variable name
39+
40+
## Testing Locally
41+
```bash
42+
cd server
43+
docker build \
44+
--build-arg GH_CLIENT_ID=Ov23liWFBY2V44492XIc \
45+
--build-arg GH_CLIENT_SECRET=dfbbb128f1f780f9b92196752e7017c7e1f8cc51 \
46+
--build-arg GH_REDIRECT_URI=https://tracker.nesohq.org/auth/callback \
47+
--build-arg CORS_ORIGIN=https://tracker.nesohq.org \
48+
-t server-test .
49+
50+
docker run -p 3001:3001 server-test
51+
52+
# Test the config endpoint
53+
curl http://localhost:3001/api/auth/config
54+
# Should return: {"client_id":"...","redirect_uri":"https://tracker.nesohq.org/auth/callback"}
55+
```

server/.env.example

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ GH_CLIENT_SECRET=your_client_secret
77
# redirect_uri to the frontend. Must exactly match the "Authorization callback URL"
88
# set in your GitHub OAuth app settings.
99
# Example:
10-
# GH_REDIRECT_URI=https://your-domain.com/oauth/callback
10+
GH_REDIRECT_URI=https://your-domain.com/auth/callback
1111

1212
# Server port (default: 3001)
1313
# PORT=3001
1414

1515
# Allowed CORS origins (comma-separated). Required in production when the
1616
# frontend and backend are on different origins.
17-
# CORS_ORIGIN=https://your-domain.com
17+
CORS_ORIGIN=https://your-domain.com

server/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ ENV NODE_ENV=production
1919
# Accept build arguments for environment variables
2020
ARG GH_CLIENT_ID
2121
ARG GH_CLIENT_SECRET
22-
ARG GITHUB_REDIRECT_URI
22+
ARG GH_REDIRECT_URI
2323
ARG CORS_ORIGIN
2424

2525
# Set them as environment variables
2626
ENV GH_CLIENT_ID=$GH_CLIENT_ID
2727
ENV GH_CLIENT_SECRET=$GH_CLIENT_SECRET
28-
ENV GITHUB_REDIRECT_URI=$GITHUB_REDIRECT_URI
28+
ENV GH_REDIRECT_URI=$GH_REDIRECT_URI
2929
ENV CORS_ORIGIN=$CORS_ORIGIN
3030

3131
RUN addgroup --system --gid 1001 nodejs \

0 commit comments

Comments
 (0)