File tree Expand file tree Collapse file tree 4 files changed +12
-38
lines changed
packages/preview-server/src Expand file tree Collapse file tree 4 files changed +12
-38
lines changed Original file line number Diff line number Diff line change 1+ 'use server' ;
2+
3+ import { resendApiKey } from '../app/env' ;
4+
5+ export async function hasResendApiKey ( ) {
6+ return ( resendApiKey ?? '' ) . trim ( ) . length > 0 ;
7+ }
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -8,6 +8,9 @@ export const previewServerLocation = process.env.PREVIEW_SERVER_LOCATION!;
88export const emailsDirectoryAbsolutePath =
99 process . env . EMAILS_DIR_ABSOLUTE_PATH ! ;
1010
11+ /** ONLY ACCESSIBLE ON THE SERVER */
12+ export const resendApiKey = process . env . RESEND_API_KEY ;
13+
1114export const isBuilding = process . env . NEXT_PUBLIC_IS_BUILDING === 'true' ;
1215
1316export const isPreviewDevelopment =
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import { IconCloudAlert } from '../icons/icon-cloud-alert';
1111import { IconCloudCheck } from '../icons/icon-cloud-check' ;
1212import { IconLoader } from '../icons/icon-loader' ;
1313import { Results } from './results' ;
14+ import { hasResendApiKey } from '../../actions/has-resend-api-key' ;
1415
1516export interface ResendStatus {
1617 hasApiKey : boolean ;
@@ -32,27 +33,11 @@ export const useResend = ({
3233 setLoading ( true ) ;
3334
3435 try {
35- const response = await fetch ( '/api/has-resend-api-key' , {
36- method : 'GET' ,
37- headers : { 'Content-Type' : 'application/json' } ,
38- } ) ;
39-
40- const body = ( await response . json ( ) . catch ( ( ) => ( { } ) ) ) as
41- | { ok : boolean ; error : string | null }
42- | undefined ;
43-
44- if ( response . ok && body ?. ok ) {
36+ if ( await hasResendApiKey ( ) ) {
4537 const result = { hasApiKey : true , error : null } ;
4638 setStatus ( result ) ;
4739 return result ;
4840 }
49-
50- const result = {
51- hasApiKey : false ,
52- error : body ?. error ?? 'Unknown error' ,
53- } ;
54- setStatus ( result ) ;
55- return result ;
5641 } catch ( exception ) {
5742 console . error ( 'Error checking Resend API key' , exception ) ;
5843 } finally {
You can’t perform that action at this time.
0 commit comments