Skip to content

Commit 2094f8b

Browse files
committed
Merge branch 'mime-fix'
2 parents a3c1589 + 5e8e601 commit 2094f8b

File tree

1 file changed

+37
-3
lines changed

1 file changed

+37
-3
lines changed

src/lib/inngest/client.ts

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,17 @@ const isDevelopment = () => {
88
return window.location.hostname === 'localhost' || env.DEV;
99
}
1010

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';
1322
};
1423

1524
// Get event key safely based on context
@@ -21,7 +30,30 @@ const getEventKey = () => {
2130
}
2231

2332
// 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;
2557
};
2658

2759
// Create the Inngest client
@@ -31,6 +63,8 @@ export const inngest = new Inngest({
3163
isDev: isDevelopment(),
3264
// Add event key from environment (server-side only)
3365
eventKey: getEventKey(),
66+
// Add signing key for production verification
67+
signingKey: getSigningKey(),
3468
});
3569

3670
// Define event schemas for type safety

0 commit comments

Comments
 (0)