stack/apps/backend/src/stack.tsx
BilalG1 8901a93b55
Rename STACK_SEED_INTERNAL_PROJECT_SECRET_SERVER_KEY to STACK_INTERNAL_PROJECT_SECRET_SERVER_KEY (#1415)
## Summary
- Renames the env var `STACK_SEED_INTERNAL_PROJECT_SECRET_SERVER_KEY` to
`STACK_INTERNAL_PROJECT_SECRET_SERVER_KEY` everywhere it is used (20
occurrences across 8 files), covering backend env files, the Prisma seed
script, runtime config, and the docker entrypoint/local-emulator
scripts.
- Mirrors the prior publishable-client-key rename in #1411.

## Test plan
- [x] `pnpm lint`
- [x] `pnpm typecheck`
- [ ] Verify local emulator still boots with the renamed variable
- [ ] Verify any deploy/CI configs that set the old name are updated
alongside this change

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Chores**
* Updated internal environment variable naming for API key management
and server configuration consistency across backend systems, Docker
deployment, and local development setup.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-05-06 10:35:08 -07:00

24 lines
1.2 KiB
TypeScript

import { StackServerApp } from '@stackframe/stack';
import { getEnvVariable } from '@stackframe/stack-shared/dist/utils/env';
export function getStackServerApp() {
// Fail fast if the backend self-URL env var is missing — without it the SDK
// would silently inherit `defaultBaseUrl` (https://api.stack-auth.com), which
// is almost never what we want for backend self-calls.
//
// We deliberately do NOT pass it as an explicit `baseUrl` to the SDK: doing
// so collapses `resolveApiUrls` to a single-element URL list, which short-
// circuits `_withFallback` (`apiUrls.length <= 1` branch). The SDK reads the
// same env var internally and additionally appends its hardcoded fallback
// URLs, which is what the e2e-fallback-tests workflow relies on so backend
// self-calls (quota debits in email-queue-step, send-test-email, analytics
// events batch, etc.) survive a primary-port outage.
getEnvVariable('NEXT_PUBLIC_STACK_API_URL');
return new StackServerApp({
projectId: 'internal',
tokenStore: null,
publishableClientKey: getEnvVariable('STACK_INTERNAL_PROJECT_PUBLISHABLE_CLIENT_KEY'),
secretServerKey: getEnvVariable('STACK_INTERNAL_PROJECT_SECRET_SERVER_KEY'),
});
}