File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree 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' ;
54
65import { getCurrentUser } from '@/lib/auth' ;
6+ import { readServerEnv } from '@/lib/env/server-env' ;
77
88export class AdminApiDisabledError extends Error {
99 code = 'ADMIN_API_DISABLED' as const ;
@@ -30,10 +30,14 @@ export class AdminForbiddenError extends Error {
3030}
3131
3232export function assertAdminApiEnabled ( ) : void {
33- if (
34- process . env . NODE_ENV === 'production' &&
35- readServerEnv ( 'ENABLE_ADMIN_API' ) !== 'true'
36- ) {
33+ const enabled =
34+ (
35+ readServerEnv ( 'ENABLE_ADMIN_API' ) ??
36+ readServerEnv ( 'NEXT_PUBLIC_ENABLE_ADMIN' ) ??
37+ ''
38+ ) . toLowerCase ( ) === 'true' ;
39+
40+ if ( process . env . NODE_ENV === 'production' && ! enabled ) {
3741 throw new AdminApiDisabledError ( ) ;
3842 }
3943}
Original file line number Diff line number Diff line change 1+ import { readServerEnv } from '@/lib/env/server-env' ;
2+
13import { resetPasswordTemplate } from './templates/reset-password' ;
24import { mailer } from './transporter' ;
35
@@ -7,7 +9,7 @@ type Params = {
79} ;
810
911export async function sendPasswordResetEmail ( { to, resetUrl } : Params ) {
10- const from = process . env . EMAIL_FROM ;
12+ const from = readServerEnv ( ' EMAIL_FROM' ) ;
1113
1214 if ( ! from ) {
1315 throw new Error ( 'EMAIL_FROM is not configured' ) ;
Original file line number Diff line number Diff line change 1+ import { readServerEnv } from '@/lib/env/server-env' ;
2+
13import { verifyEmailTemplate } from './templates/verify-email' ;
24import { mailer } from './transporter' ;
35
@@ -7,7 +9,7 @@ type Params = {
79} ;
810
911export async function sendVerificationEmail ( { to, verifyUrl } : Params ) {
10- const from = process . env . EMAIL_FROM ;
12+ const from = readServerEnv ( ' EMAIL_FROM' ) ;
1113
1214 if ( ! from ) {
1315 throw new Error ( 'EMAIL_FROM is not configured' ) ;
Original file line number Diff line number Diff line change 11import nodemailer from 'nodemailer' ;
22
3- const user = process . env . GMAIL_USER ;
4- const pass = process . env . GMAIL_APP_PASSWORD ;
3+ import { readServerEnv } from '@/lib/env/server-env' ;
4+
5+ const user = readServerEnv ( 'GMAIL_USER' ) ;
6+ const pass = readServerEnv ( 'GMAIL_APP_PASSWORD' ) ;
57
68if ( ! user || ! pass ) {
79 throw new Error ( 'Missing Gmail SMTP credentials' ) ;
Original file line number Diff line number Diff line change @@ -44,6 +44,11 @@ const GENERATED_FALLBACK_KEYS = new Set([
4444 'ENABLE_ADMIN_API' ,
4545 'NEXT_PUBLIC_ENABLE_ADMIN' ,
4646 'SHOP_STATUS_TOKEN_SECRET' ,
47+ 'APP_ORIGIN' ,
48+ 'APP_ADDITIONAL_ORIGINS' ,
49+ 'GMAIL_USER' ,
50+ 'GMAIL_APP_PASSWORD' ,
51+ 'EMAIL_FROM' ,
4752] ) ;
4853
4954
Original file line number Diff line number Diff line change 11import { NextRequest , NextResponse } from 'next/server' ;
22
3+ import { readServerEnv } from '@/lib/env/server-env' ;
4+
35const LOCALHOST_ORIGIN = 'http://localhost:3000' ;
46
57function buildErrorResponse (
@@ -49,13 +51,13 @@ export function normalizeOrigin(input: string): string {
4951export function getAllowedOrigins ( ) : string [ ] {
5052 const allowed = new Set < string > ( ) ;
5153
52- const appOrigin = ( process . env . APP_ORIGIN ?? '' ) . trim ( ) ;
54+ const appOrigin = ( readServerEnv ( ' APP_ORIGIN' ) ?? '' ) . trim ( ) ;
5355 if ( appOrigin ) {
5456 const normalized = normalizeOrigin ( appOrigin ) ;
5557 if ( normalized ) allowed . add ( normalized ) ;
5658 }
5759
58- const additionalRaw = ( process . env . APP_ADDITIONAL_ORIGINS ?? '' ) . trim ( ) ;
60+ const additionalRaw = ( readServerEnv ( ' APP_ADDITIONAL_ORIGINS' ) ?? '' ) . trim ( ) ;
5961 if ( additionalRaw ) {
6062 for ( const entry of additionalRaw . split ( ',' ) ) {
6163 const candidate = entry . trim ( ) ;
Original file line number Diff line number Diff line change 11import crypto from 'node:crypto' ;
2+
23import { readServerEnv } from '@/lib/env/server-env' ;
34
45export const STATUS_TOKEN_SCOPES = [
You can’t perform that action at this time.
0 commit comments