File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import { ThemeProvider } from '@/components/theme/ThemeProvider';
1313import { getCachedBlogCategories } from '@/db/queries/blog/blog-categories' ;
1414import { AuthProvider } from '@/hooks/useAuth' ;
1515import { locales } from '@/i18n/config' ;
16+ import { readServerEnv } from '@/lib/env/server-env' ;
1617
1718export default async function LocaleLayout ( {
1819 children,
@@ -32,8 +33,8 @@ export default async function LocaleLayout({
3233
3334 const enableAdmin =
3435 (
35- process . env . ENABLE_ADMIN_API ??
36- process . env . NEXT_PUBLIC_ENABLE_ADMIN ??
36+ readServerEnv ( ' ENABLE_ADMIN_API' ) ??
37+ readServerEnv ( ' NEXT_PUBLIC_ENABLE_ADMIN' ) ??
3738 ''
3839 ) . toLowerCase ( ) === 'true' ;
3940
Original file line number Diff line number Diff line change 11import 'server-only' ;
22
33import type { NextRequest } from 'next/server' ;
4+ import { readServerEnv } from '@/lib/env/server-env' ;
45
56import { getCurrentUser } from '@/lib/auth' ;
67
@@ -31,7 +32,7 @@ export class AdminForbiddenError extends Error {
3132export function assertAdminApiEnabled ( ) : void {
3233 if (
3334 process . env . NODE_ENV === 'production' &&
34- process . env . ENABLE_ADMIN_API !== 'true'
35+ readServerEnv ( ' ENABLE_ADMIN_API' ) !== 'true'
3536 ) {
3637 throw new AdminApiDisabledError ( ) ;
3738 }
Original file line number Diff line number Diff line change @@ -41,6 +41,9 @@ const GENERATED_FALLBACK_KEYS = new Set([
4141 'GITHUB_CLIENT_ID_DEVELOP' ,
4242 'GITHUB_CLIENT_SECRET_DEVELOP' ,
4343 'GITHUB_CLIENT_REDIRECT_URI_DEVELOP' ,
44+ 'ENABLE_ADMIN_API' ,
45+ 'NEXT_PUBLIC_ENABLE_ADMIN' ,
46+ 'SHOP_STATUS_TOKEN_SECRET' ,
4447] ) ;
4548
4649
Original file line number Diff line number Diff line change 11import crypto from 'node:crypto' ;
2+ import { readServerEnv } from '@/lib/env/server-env' ;
23
34export const STATUS_TOKEN_SCOPES = [
45 'status_lite' ,
@@ -27,7 +28,7 @@ type TokenPayload = {
2728const DEFAULT_TTL_SECONDS = 45 * 60 ;
2829
2930function getSecret ( ) : string {
30- const raw = process . env . SHOP_STATUS_TOKEN_SECRET ?? '' ;
31+ const raw = readServerEnv ( ' SHOP_STATUS_TOKEN_SECRET' ) ?? '' ;
3132 const trimmed = raw . trim ( ) ;
3233 if ( ! trimmed ) {
3334 throw new Error ( 'SHOP_STATUS_TOKEN_SECRET is not configured' ) ;
You can’t perform that action at this time.
0 commit comments