485e220c49
- Throw at startup in production if REDIS_URL/DATABASE_URL/NEXTAUTH_SECRET missing - Warn in development when REDIS_URL falls back to localhost - QueryClient: add gcTime, disable refetchOnWindowFocus, skip retry on 4xx Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
27 lines
954 B
TypeScript
27 lines
954 B
TypeScript
export async function register() {
|
|
// Validate required env vars at startup — throws immediately in production
|
|
// if REDIS_URL, DATABASE_URL, or NEXTAUTH_SECRET are missing.
|
|
if (process.env.NEXT_RUNTIME === "nodejs") {
|
|
const { assertProductionEnv } = await import("@capakraken/api");
|
|
assertProductionEnv();
|
|
}
|
|
|
|
// Only load Sentry in production — the worker.js crash in dev mode
|
|
// (vendor-chunks/lib/worker.js MODULE_NOT_FOUND) makes the dev server unstable
|
|
if (process.env.NODE_ENV === "production") {
|
|
if (process.env.NEXT_RUNTIME === "nodejs") {
|
|
await import("../sentry.server.config");
|
|
}
|
|
if (process.env.NEXT_RUNTIME === "edge") {
|
|
await import("../sentry.edge.config");
|
|
}
|
|
}
|
|
}
|
|
|
|
export async function onRequestError(...args: unknown[]) {
|
|
if (process.env.NODE_ENV === "production") {
|
|
const Sentry = await import("@sentry/nextjs");
|
|
(Sentry.captureRequestError as Function)(...args);
|
|
}
|
|
}
|