Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
afae79b
Customizable ports
N2D4 Oct 17, 2025
8a76453
Update
N2D4 Oct 17, 2025
4433317
fix types
N2D4 Oct 17, 2025
915252d
fix lint
N2D4 Oct 17, 2025
f4e3b9a
Merge branch 'dev' into customizable-ports
N2D4 Oct 17, 2025
eb5662c
Update title
N2D4 Oct 17, 2025
a20ccaa
fix tests
N2D4 Oct 17, 2025
8e880cc
more fixes
N2D4 Oct 17, 2025
4caefb1
more fixes
N2D4 Oct 17, 2025
0550e2f
fix
N2D4 Oct 17, 2025
60410a3
fix
N2D4 Oct 17, 2025
f441c50
better
N2D4 Oct 17, 2025
2c04b0a
fix
N2D4 Oct 17, 2025
abdad07
No more config twiddling
N2D4 Oct 17, 2025
faf2157
chore(docs): update TOC
N2D4 Oct 17, 2025
184e9e6
Rename envvar
N2D4 Oct 17, 2025
d6ed716
fixes
N2D4 Oct 17, 2025
7c4c8ba
Merge branch 'dev' into customizable-ports
N2D4 Oct 17, 2025
8400777
more
N2D4 Oct 17, 2025
5c2a55c
fixes
N2D4 Oct 17, 2025
51860cc
fixes
N2D4 Oct 17, 2025
3774341
fixes
N2D4 Oct 17, 2025
14eafbb
fix
N2D4 Oct 17, 2025
f1d479a
more test fixes
N2D4 Oct 17, 2025
30f5592
fix
N2D4 Oct 17, 2025
52c398d
fix
N2D4 Oct 17, 2025
7ccc830
fix wildcard domains test
N2D4 Oct 17, 2025
cab12f0
stuff
N2D4 Oct 17, 2025
434d1bf
fix emulator
N2D4 Oct 17, 2025
c796ebf
Customizable ports docs
N2D4 Oct 17, 2025
0f5c776
disable emulator workflow
N2D4 Oct 17, 2025
7c699a5
improve process names
N2D4 Oct 17, 2025
8e4574e
Merge dev into customizable-ports
N2D4 Oct 18, 2025
f42efeb
Merge dev into customizable-ports
N2D4 Oct 19, 2025
75c2595
Merge branch 'dev' into customizable-ports
N2D4 Oct 20, 2025
76ef55f
REmove ppr
N2D4 Oct 20, 2025
ba0ec30
Merge branch 'dev' into customizable-ports
N2D4 Oct 20, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update
  • Loading branch information
N2D4 committed Oct 17, 2025
commit 8a76453b5655edfaa951ce0296af6a0c29328259
2 changes: 1 addition & 1 deletion .claude/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"hooks": [
{
"type": "command",
"command": "if ! curl -s --connect-timeout 1 http://localhost:8102 >/dev/null 2>&1; then echo -e '\\n\\n\\033[1;31mCannot reach backend on port 8102! Please run `pnpm run dev` before querying Claude Code\\033[0m\\n\\n' >&2; exit 2; fi"
"command": "PORT=${STACK_PORT_PREFIX:-81}02; if ! curl -s --connect-timeout 1 \"http://localhost:$PORT\" >/dev/null 2>&1; then echo -e \"\\n\\n\\033[1;31mCannot reach backend on port $PORT! Please run \\`pnpm run dev\\` before querying Claude Code\\033[0m\\n\\n\" >&2; exit 2; fi"
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
}
]
}
Expand Down
153 changes: 153 additions & 0 deletions .github/workflows/e2e-custom-base-port-api-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
name: Runs E2E API Tests

on:
push:
branches:
- main
- dev
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/dev' }}

jobs:
build:
runs-on: ubicloud-standard-8
env:
NODE_ENV: test
STACK_ENABLE_HARDCODED_PASSKEY_CHALLENGE_FOR_TESTING: yes
STACK_DIRECT_DATABASE_CONNECTION_STRING: "postgres://postgres:PASSWORD-PLACEHOLDER--uqfEC1hmmv@localhost:6728/stackframe"
Comment thread
N2D4 marked this conversation as resolved.
STACK_PORT_PREFIX: "67"

strategy:
matrix:
node-version: [22.x]

steps:
- uses: actions/checkout@v3

- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Setup pnpm
uses: pnpm/action-setup@v3
with:
version: 9.1.2

# Even just starting the Docker Compose as a daemon is slow because we have to download and build the images
# so, we run it in the background
- name: Start Docker Compose in background
uses: JarvusInnovations/background-action@v1.0.7
with:
run: docker compose -f docker/dependencies/docker.compose.yaml up -d &
# we don't need to wait on anything, just need to start the daemon
wait-on: /dev/null
tail: true
wait-for: 3s
log-output-if: true

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Create .env.test.local file for apps/backend
run: cp apps/backend/.env.development apps/backend/.env.test.local

- name: Create .env.test.local file for apps/dashboard
run: cp apps/dashboard/.env.development apps/dashboard/.env.test.local

- name: Create .env.test.local file for apps/e2e
run: cp apps/e2e/.env.development apps/e2e/.env.test.local

- name: Create .env.test.local file for docs
run: cp docs/.env.development docs/.env.test.local

- name: Create .env.test.local file for examples/cjs-test
run: cp examples/cjs-test/.env.development examples/cjs-test/.env.test.local

- name: Create .env.test.local file for examples/demo
run: cp examples/demo/.env.development examples/demo/.env.test.local

- name: Create .env.test.local file for examples/docs-examples
run: cp examples/docs-examples/.env.development examples/docs-examples/.env.test.local

- name: Create .env.test.local file for examples/e-commerce
run: cp examples/e-commerce/.env.development examples/e-commerce/.env.test.local

- name: Create .env.test.local file for examples/middleware
run: cp examples/middleware/.env.development examples/middleware/.env.test.local

- name: Create .env.test.local file for examples/partial-prerendering
run: cp examples/partial-prerendering/.env.development examples/partial-prerendering/.env.test.local

- name: Create .env.test.local file for examples/supabase
run: cp examples/supabase/.env.development examples/supabase/.env.test.local

- name: Create .env.test.local file for examples/convex
run: cp examples/convex/.env.development examples/convex/.env.test.local

- name: Build
run: pnpm build

- name: Wait on Postgres
run: pnpm run wait-until-postgres-is-ready:pg_isready

- name: Wait on Inbucket
run: npx wait-on tcp:localhost:8129

- name: Wait on Svix
run: npx wait-on tcp:localhost:8113
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Port Configuration Mismatch in Workflow

The workflow sets STACK_PORT_PREFIX to "67", but wait-on commands for Inbucket, Svix, and the backend/dashboard/mock-oauth-server use hardcoded default ports (8129, 8113, 8102). This causes the workflow to attempt to wait on incorrect ports, rather than those derived from the STACK_PORT_PREFIX (e.g., 6729, 6713, 6702).

Fix in Cursor Fix in Web


- name: Initialize database
run: pnpm run db:init

- name: Start stack-backend in background
uses: JarvusInnovations/background-action@v1.0.7
with:
run: pnpm run start:backend --log-order=stream &
wait-on: |
http://localhost:8102
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Critical: Port mismatch in wait-on URLs.

The workflow sets STACK_PORT_PREFIX: "67" (Line 21), but the wait-on URLs are hardcoded to http://localhost:8102. With a prefix of 67, the backend should be running on port 6702. This mismatch will cause the workflow to fail as it waits for services on the wrong port.

Apply this diff to fix the port references:

       - name: Start stack-backend in background
         uses: JarvusInnovations/background-action@v1.0.7
         with:
           run: pnpm run start:backend --log-order=stream &
           wait-on: |
-            http://localhost:8102
+            http://localhost:6702
           tail: true
           wait-for: 30s
           log-output-if: true
       - name: Start stack-dashboard in background
         uses: JarvusInnovations/background-action@v1.0.7
         with:
           run: pnpm run start:dashboard --log-order=stream &
           wait-on: |
-            http://localhost:8102
+            http://localhost:6701
           tail: true
           wait-for: 30s
           log-output-if: true
       - name: Start mock-oauth-server in background
         uses: JarvusInnovations/background-action@v1.0.7
         with:
           run: pnpm run start:mock-oauth-server --log-order=stream &
           wait-on: |
-            http://localhost:8102
+            http://localhost:6707
           tail: true
           wait-for: 30s
           log-output-if: true

Also applies to: 120-120, 129-129

🤖 Prompt for AI Agents
.github/workflows/e2e-custom-base-port-api-tests.yaml around line 111 (also
applies to lines 120 and 129): the wait-on URLs are hardcoded to
http://localhost:8102 while the workflow sets STACK_PORT_PREFIX: "67", so update
those URLs to use the correct port constructed from the prefix (e.g., 6702) or
interpolate the STACK_PORT_PREFIX env var into the port (STACK_PORT_PREFIX +
"02") so the wait-on targets match the actual backend port.

tail: true
wait-for: 30s
log-output-if: true
- name: Start stack-dashboard in background
uses: JarvusInnovations/background-action@v1.0.7
with:
run: pnpm run start:dashboard --log-order=stream &
wait-on: |
http://localhost:8102
tail: true
wait-for: 30s
log-output-if: true
- name: Start mock-oauth-server in background
uses: JarvusInnovations/background-action@v1.0.7
with:
run: pnpm run start:mock-oauth-server --log-order=stream &
wait-on: |
http://localhost:8102
Comment thread
vercel[bot] marked this conversation as resolved.
Outdated
tail: true
wait-for: 30s
log-output-if: true

- name: Wait 10 seconds
run: sleep 10

- name: Run tests
run: pnpm test

- name: Run tests again, to make sure they are stable (attempt 1)
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev'
run: pnpm test

- name: Run tests again, to make sure they are stable (attempt 2)
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev'
run: pnpm test

- name: Verify data integrity
run: pnpm run verify-data-integrity

- name: Print Docker Compose logs
if: always()
run: docker compose -f docker/dependencies/docker.compose.yaml logs
6 changes: 3 additions & 3 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ You should ALWAYS add new E2E tests when you change the API or SDK interface. Ge
Stack Auth is a monorepo using Turbo for build orchestration. The main components are:

### Apps (`/apps`)
- **backend** (`/apps/backend`): Next.js API backend running on port 8102
- **backend** (`/apps/backend`): Next.js API backend running on port `<$STACK_PORT_PREFIX>02` (defaults to 8102)
- Main API routes in `/apps/backend/src/app/api/latest`
- Database models using Prisma
- **dashboard** (`/apps/dashboard`): Admin dashboard on port 8101
- **dev-launchpad**: Development portal on port 8100
- **dashboard** (`/apps/dashboard`): Admin dashboard on port `<$STACK_PORT_PREFIX>01` (defaults to 8101)
- **dev-launchpad**: Development portal on port `<$STACK_PORT_PREFIX>00` (defaults to 8100)
- **e2e**: End-to-end tests

### Packages (`/packages`)
Expand Down
6 changes: 3 additions & 3 deletions apps/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
"typecheck": "tsc --noEmit",
"with-env": "dotenv -c development --",
"with-env:prod": "dotenv -c --",
"dev": "concurrently -n \"dev,codegen,prisma-studio\" -k \"next dev --turbopack --port 8102\" \"pnpm run codegen:watch\" \"pnpm run prisma-studio\"",
"dev": "concurrently -n \"dev,codegen,prisma-studio\" -k \"next dev --turbopack --port ${STACK_PORT_PREFIX:-81}02\" \"pnpm run codegen:watch\" \"pnpm run prisma-studio\"",
"build": "pnpm run codegen && next build",
"docker-build": "pnpm run codegen && next build --experimental-build-mode compile",
"build-self-host-migration-script": "tsup --config scripts/db-migrations.tsup.config.ts",
"analyze-bundle": "ANALYZE_BUNDLE=1 pnpm run build",
"start": "next start --port 8102",
"start": "next start --port ${STACK_PORT_PREFIX:-81}02",
"codegen-prisma": "pnpm run prisma generate",
"codegen-prisma:watch": "pnpm run prisma generate --watch",
"codegen-route-info": "pnpm run with-env tsx scripts/generate-route-info.ts",
Expand All @@ -21,7 +21,7 @@
"codegen:watch": "concurrently -n \"prisma,docs,route-info,migration-imports\" -k \"pnpm run codegen-prisma:watch\" \"pnpm run watch-docs\" \"pnpm run codegen-route-info:watch\" \"pnpm run generate-migration-imports:watch\"",
"psql-inner": "psql $(echo $STACK_DATABASE_CONNECTION_STRING | sed 's/\\?.*$//')",
"psql": "pnpm run with-env pnpm run psql-inner",
"prisma-studio": "pnpm run with-env prisma studio --port 8106 --browser none",
"prisma-studio": "pnpm run with-env prisma studio --port ${STACK_PORT_PREFIX:-81}06 --browser none",
"prisma": "pnpm run with-env prisma",
"db:migration-gen": "pnpm run with-env tsx scripts/db-migrations.ts generate-migration-file",
"db:reset": "pnpm run with-env tsx scripts/db-migrations.ts reset",
Expand Down
3 changes: 2 additions & 1 deletion apps/backend/src/lib/freestyle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ export class Freestyle {
if (!["development", "test"].includes(getNodeEnvironment())) {
throw new StackAssertionError("Mock Freestyle key used in production; please set the STACK_FREESTYLE_API_KEY environment variable.");
}
baseUrl = "http://localhost:8122";
const prefix = getEnvVariable("STACK_PORT_PREFIX", "81");
baseUrl = `http://localhost:${prefix}22`;
}
this.freestyle = new FreestyleSandboxes({
apiKey,
Expand Down
3 changes: 2 additions & 1 deletion apps/backend/src/lib/stripe.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ import { createStripeProxy, type StripeOverridesMap } from "./stripe-proxy";

const stripeSecretKey = getEnvVariable("STACK_STRIPE_SECRET_KEY");
const useStripeMock = stripeSecretKey === "sk_test_mockstripekey" && ["development", "test"].includes(getNodeEnvironment());
const stackPortPrefix = getEnvVariable("STACK_PORT_PREFIX", "81");
const stripeConfig: Stripe.StripeConfig = useStripeMock ? {
protocol: "http",
host: "localhost",
port: 8123,
port: Number(`${stackPortPrefix}23`),
} : {};

export const getStackStripe = (overrides?: StripeOverridesMap) => {
Expand Down
4 changes: 2 additions & 2 deletions apps/dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
"typecheck": "tsc --noEmit",
"with-env": "dotenv -c development --",
"with-env:prod": "dotenv -c --",
"dev": "next dev --turbopack --port 8101",
"dev": "next dev --turbopack --port ${STACK_PORT_PREFIX:-81}01",
"build": "next build",
"docker-build": "next build --experimental-build-mode compile",
"analyze-bundle": "ANALYZE_BUNDLE=1 pnpm run build",
"start": "next start --port 8101",
"start": "next start --port ${STACK_PORT_PREFIX:-81}01",
"psql": "pnpm run with-env bash -c 'psql $STACK_DATABASE_CONNECTION_STRING'",
"lint": "next lint"
},
Expand Down
1 change: 1 addition & 0 deletions apps/dev-launchpad/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
public/env-config.js
2 changes: 1 addition & 1 deletion apps/dev-launchpad/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "2.8.43",
"private": true,
"scripts": {
"dev": "serve -p 8100 -s public",
"dev": "node scripts/write-env-config.js && serve -p ${STACK_PORT_PREFIX:-81}00 -s public",
"clean": "rimraf node_modules"
},
"dependencies": {
Expand Down
Loading
Loading