stack/apps/backend/src/stack.tsx
Bilal Godil 8fc11e1c93 Rename Stack -> Hexclave in examples, app-internal symbols, and crypto docs
- examples: rename the user config module stack.ts/.tsx (and the convex/lovable
  stack/ dirs) to hexclave and update all importers across .ts/.tsx/.jsx; the
  public handler/[...stack] route segment is left unchanged.
- apps/{dashboard,backend,internal-tool}: rename app-local SDK-init symbols
  (stackClientApp -> hexclaveClientApp, getStackServerApp -> getHexclaveServerApp)
  and the dashboard StackCompanion component -> HexclaveCompanion. The public
  StackClientApp/StackServerApp SDK classes are intentionally left unchanged.
- packages/stack-shared: add comments explaining why the crypto/JWT/vault
  "stack-*" literals must NOT be renamed (key derivation / JWKS / KMS-alias
  stability would break existing encrypted data and tokens).

Deliberately excluded: the STACK_* -> HEXCLAVE_* env-var rename (already works via
the dual-read layers; the docker post-build sentinel path is author-deferred), and
all public-contract names (SDK classes, env vars, HTTP headers, handler routes).
2026-06-01 17:20:35 -07:00

24 lines
1.2 KiB
TypeScript

import { StackServerApp } from '@hexclave/next';
import { getEnvVariable } from '@hexclave/shared/dist/utils/env';
export function getHexclaveServerApp() {
// 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'),
});
}