Skip to content

Commit 3d675e8

Browse files
committed
handling default
1 parent b6ff6bd commit 3d675e8

File tree

3 files changed

+33
-8
lines changed

3 files changed

+33
-8
lines changed

.env

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ VUE_APP_GITHUB_ENT=
1515
VUE_APP_GITHUB_TOKEN=
1616

1717
# GitHub Api Url
18-
# for proxy api - set to /api/github
19-
VUE_APP_GITHUB_API_URL=https://api.github.com
18+
# for proxy api - set to /api/github defaults to https://api.github.com
19+
VUE_APP_GITHUB_API=

README.md

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,18 +157,44 @@ For deployed version use the Uri of your app.
157157

158158
To build and run the app with API proxy:
159159

160-
```
161-
docker build -t copilot-metrics-viewer-with-api -f api.Dockerfile .
160+
```bash
161+
docker build -t copilot-metrics-viewer-with-proxy -f api.Dockerfile .
162162
```
163163

164164
To run:
165165

166+
```bash
167+
docker run -it --rm -p 8080:3000 --env-file ./.env copilot-metrics-viewer-with-proxy
166168
```
167-
docker run -it --rm -p 8080:3000 --env-file ./.env copilot-metrics-viewer-with-api
169+
170+
Proxy can also run with token hardcoded on the backend (which hides it from frontend calls), here's a sample:
171+
172+
```bash
173+
docker run -it --rm -p 3000:3000 \
174+
-e VUE_APP_SCOPE=enterprise \
175+
-e VUE_APP_GITHUB_API=/api/github \
176+
-e VUE_APP_GITHUB_ENT=<enterprise name> \
177+
-e VUE_APP_GITHUB_TOKEN=<github PAT> \
178+
-e SESSION_SECRET=<random string> \
179+
copilot-metrics-viewer-with-proxy
180+
```
181+
182+
or
183+
184+
```bash
185+
docker run -it --rm -p 3000:3000 \
186+
-e VUE_APP_SCOPE=organization \
187+
-e VUE_APP_GITHUB_API=/api/github \
188+
-e VUE_APP_GITHUB_ORG=<org name> \
189+
-e VUE_APP_GITHUB_TOKEN=<github PAT> \
190+
-e SESSION_SECRET=<random string> \
191+
copilot-metrics-viewer-with-api
168192
```
169193

170194
### Github App Registration
171195

196+
While it is possible to run API Proxy without GitHub app registration and with hardcoded token, it's the recommended way.
197+
172198
Go to Organization -> Settings -> Developer Settings section -> GitHub Apps -> New GitHub App
173199

174200
Replace <your org> with your organization name in the link:
@@ -230,7 +256,6 @@ docker run -it --rm -p 3000:3000 \
230256
ghcr.io/karpikpl/copilot-metrics-viewer-with-proxy
231257
```
232258

233-
234259
## License
235260

236261
This project is licensed under the terms of the MIT open source license. Please refer to [MIT](./LICENSE.txt) for the full terms.

src/config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ const baseApi = env.VUE_APP_GITHUB_API;
2727
let scopeName: string;
2828
if (scopeType === 'organization') {
2929
scopeName = githubOrgName;
30-
apiUrl = `${baseApi ?? 'https://api.github.com'}/orgs/${githubOrgName}`;
30+
apiUrl = `${baseApi || 'https://api.github.com'}/orgs/${githubOrgName}`;
3131
}
3232
else if (scopeType === 'enterprise') {
3333
scopeName = githubEntName;
34-
apiUrl = `${baseApi ?? 'https://api.github.com'}/enterprises/${githubEntName}`;
34+
apiUrl = `${baseApi || 'https://api.github.com'}/enterprises/${githubEntName}`;
3535
}
3636
else {
3737
throw new Error(`Invalid VUE_APP_SCOPE value: ${env.VUE_APP_SCOPE}. Valid values: ${VALID_SCOPE.join(', ')}`)

0 commit comments

Comments
 (0)