Skip to content

Commit 8e71f18

Browse files
authored
Dev container for codespaces (stack-auth#610)
1 parent 3940e58 commit 8e71f18

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

.devcontainer/devcontainer.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"ghcr.io/devcontainers-contrib/features/pnpm:2": {
1010
"version": "9"
1111
},
12-
"ghcr.io/devcontainers/features/git:1": {}
12+
"ghcr.io/devcontainers/features/git:1": {},
13+
"github-cli": "latest"
1314
},
1415
"hostRequirements": {
1516
"cpus": 2,
@@ -31,8 +32,9 @@
3132
8180, 8181, 8182, 8183, 8184, 8185, 8186, 8187, 8188, 8189,
3233
8190, 8191, 8192, 8193, 8194, 8195, 8196, 8197, 8198, 8199
3334
],
34-
"postCreateCommand": "pnpm install && pnpm build:packages && pnpm codegen && pnpm run start-deps && pnpm run stop-deps",
35-
"postStartCommand": "pnpm install && clear && echo 'To start the development server with dependencies, run: pnpm restart-deps && pnpm dev' && echo 'To run the tests, run: pnpm test [<path-filter>]'",
35+
"postCreateCommand": "chmod +x .devcontainer/set-env.sh && pnpm install && pnpm build:packages && pnpm codegen && pnpm run start-deps && pnpm run stop-deps",
36+
"postStartCommand": "pnpm install && clear",
37+
"postAttachCommand": ". .devcontainer/set-env.sh",
3638
"customizations": {
3739
"vscode": {
3840
"extensions": [

.devcontainer/set-env.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
if [ -n "$CODESPACE_NAME" ]; then
4+
export NEXT_PUBLIC_STACK_API_URL="https://${CODESPACE_NAME}-8102.app.github.dev"
5+
export STACK_MOCK_OAUTH_REDIRECT_URIS="https://${CODESPACE_NAME}-8102.app.github.dev/api/v1/auth/oauth/callback/{id}"
6+
export NEXT_PUBLIC_STACK_DASHBOARD_URL="https://${CODESPACE_NAME}-8101.app.github.dev"
7+
gh codespace ports visibility 8102:public -c $CODESPACE_NAME && gh codespace ports visibility 8114:public -c $CODESPACE_NAME
8+
fi
9+
10+
echo 'To start the development server with dependencies, run: pnpm restart-deps && pnpm dev'

apps/mock-oauth-server/src/index.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,12 @@ const providerIds = [
1818
const clients = providerIds.map((id) => ({
1919
client_id: id,
2020
client_secret: 'MOCK-SERVER-SECRET',
21-
redirect_uris: [8102, 32102].map(port =>
22-
`http://localhost:${port}/api/v1/auth/oauth/callback/${id}`
23-
),
21+
redirect_uris: [
22+
...([8102, 32102].map(port =>
23+
`http://localhost:${port}/api/v1/auth/oauth/callback/${id}`
24+
)),
25+
...(process.env.STACK_MOCK_OAUTH_REDIRECT_URIS ? [process.env.STACK_MOCK_OAUTH_REDIRECT_URIS.replace("{id}", id)] : [])
26+
]
2427
}));
2528

2629
const configuration = {

0 commit comments

Comments
 (0)