@@ -8,8 +8,17 @@ const isDevelopment = () => {
8
8
return window . location . hostname === 'localhost' || env . DEV ;
9
9
}
10
10
11
- // Server environment
12
- return env . MODE === 'development' ;
11
+ // Server environment - check multiple indicators
12
+ const nodeEnv = process . env . NODE_ENV ;
13
+ const netlifyContext = process . env . CONTEXT ;
14
+
15
+ // Explicitly check for production context
16
+ if ( netlifyContext === 'production' || nodeEnv === 'production' ) {
17
+ return false ;
18
+ }
19
+
20
+ // Default to development for safety
21
+ return env . MODE === 'development' || nodeEnv !== 'production' ;
13
22
} ;
14
23
15
24
// Get event key safely based on context
@@ -21,7 +30,30 @@ const getEventKey = () => {
21
30
}
22
31
23
32
// Server context - access the real event key securely
24
- return serverEnv . INNGEST_EVENT_KEY || 'dev-key' ;
33
+ const eventKey = serverEnv . INNGEST_EVENT_KEY || process . env . INNGEST_EVENT_KEY ;
34
+
35
+ // In production, ensure we have a real key
36
+ if ( ! isDevelopment ( ) && ( ! eventKey || eventKey === 'dev-key' ) ) {
37
+ console . warn ( '[Inngest] Production environment detected but no valid event key found' ) ;
38
+ }
39
+
40
+ return eventKey || 'dev-key' ;
41
+ } ;
42
+
43
+ // Get signing key for production
44
+ const getSigningKey = ( ) => {
45
+ if ( typeof window !== 'undefined' ) {
46
+ return undefined ; // Not needed in browser
47
+ }
48
+
49
+ const signingKey = serverEnv . INNGEST_SIGNING_KEY || process . env . INNGEST_SIGNING_KEY ;
50
+
51
+ // In production, we need a signing key
52
+ if ( ! isDevelopment ( ) && ! signingKey ) {
53
+ console . warn ( '[Inngest] Production environment detected but no signing key found' ) ;
54
+ }
55
+
56
+ return signingKey ;
25
57
} ;
26
58
27
59
// Create the Inngest client
@@ -31,6 +63,8 @@ export const inngest = new Inngest({
31
63
isDev : isDevelopment ( ) ,
32
64
// Add event key from environment (server-side only)
33
65
eventKey : getEventKey ( ) ,
66
+ // Add signing key for production verification
67
+ signingKey : getSigningKey ( ) ,
34
68
} ) ;
35
69
36
70
// Define event schemas for type safety
0 commit comments