diff --git a/.claude/CLAUDE-KNOWLEDGE.md b/.claude/CLAUDE-KNOWLEDGE.md index cedbec177..8fe6c8c93 100644 --- a/.claude/CLAUDE-KNOWLEDGE.md +++ b/.claude/CLAUDE-KNOWLEDGE.md @@ -302,20 +302,6 @@ it("test name", async ({ expect }) => { ### Q: Where is project ownership stored in the database? A: Projects have an `ownerTeamId` field in the Project model (see `/apps/backend/prisma/schema.prisma`). This links to a team in the internal project. -### Q: How do I make authenticated API calls from dashboard server actions? -A: Get the session cookie and include it in the request headers: -```typescript -const cookieStore = await cookies(); -const sessionCookie = cookieStore.get("stack-refresh-internal"); -const response = await fetch(url, { - headers: { - 'X-Stack-Access-Type': 'server', - 'X-Stack-Project-Id': 'internal', - 'X-Stack-Secret-Server-Key': getEnvVariable('STACK_SECRET_SERVER_KEY'), - ...(sessionCookie ? { 'Cookie': `${sessionCookie.name}=${sessionCookie.value}` } : {}) - } -}); -``` ### Q: What's the difference between ensureTeamMembershipExists and ensureUserTeamPermissionExists? A: `ensureTeamMembershipExists` only checks if a user is a member of a team. `ensureUserTeamPermissionExists` checks if a user has a specific permission (like `team_admin`) within that team. The latter also calls `ensureTeamMembershipExists` internally. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8a0f24d06..bc44d87a4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -77,6 +77,8 @@ eval "$(direnv export )" When you do this, it is recommended that you give all workspaces a port prefix other than 81, to prevent accidental conflicts when you forgot to make a feature support the $NEXT_PUBLIC_STACK_PORT_PREFIX environment variable. (for example: first workspace at 181, second workspace at 182, etc.) +Also, the cookies on different ports may conflict with each other. To prevent this, open `a.localhost:18101` and `b.localhost:18201` instead or normal localhost, so the cookies are scoped differently. + ## Before creating a pull request Please make sure to: diff --git a/apps/dashboard/src/app/layout.tsx b/apps/dashboard/src/app/layout.tsx index ad639e65f..677cf04f3 100644 --- a/apps/dashboard/src/app/layout.tsx +++ b/apps/dashboard/src/app/layout.tsx @@ -100,6 +100,7 @@ export default function RootLayout({ {children} + @@ -112,3 +113,27 @@ export default function RootLayout({ ); } + +function DevelopmentPortDisplay() { + const prefix = getPublicEnvVar("NEXT_PUBLIC_STACK_PORT_PREFIX"); + if (!prefix) return null; + const color = ({ + "91": "#eee", + "92": "#e0e0ff", + "93": "#fff8e0", + } as any)[prefix as any] || undefined; + return ( +
+ + DEV PORT: {prefix}xx +
+ ); +} diff --git a/apps/dev-launchpad/public/index.html b/apps/dev-launchpad/public/index.html index f7746c33b..7eb4d408c 100644 --- a/apps/dev-launchpad/public/index.html +++ b/apps/dev-launchpad/public/index.html @@ -113,7 +113,11 @@ const withPrefix = (suffix) => `${stackPortPrefix}${suffix}`; // Depending on the port prefix, set the color to light grey (port 91), light purple (port 92), papyrus yellow (port 93), or default otherwise - const color = stackPortPrefix === "91" ? "#f8f8f8" : stackPortPrefix === "92" ? "#e0e0ff" : stackPortPrefix === "93" ? "#fff8e0" : undefined; + const color = { + "91": "#f8f8f8", + "92": "#e0e0ff", + "93": "#fff8e0", + }[stackPortPrefix] || undefined; document.body.style.backgroundColor = color; const backgroundServices = [