-
Notifications
You must be signed in to change notification settings - Fork 513
Expand file tree
/
Copy pathstack.tsx
More file actions
23 lines (22 loc) · 1.2 KB
/
stack.tsx
File metadata and controls
23 lines (22 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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_SEED_INTERNAL_PROJECT_SECRET_SERVER_KEY'),
});
}