Remove client-side Wren API key validation
All checks were successful
Build and Push Docker Images / docker (push) Successful in 2m30s
All checks were successful
Build and Push Docker Images / docker (push) Successful in 2m30s
The config.ts file was still checking for NEXT_PUBLIC_WREN_API_TOKEN which no longer exists after moving to server-side proxy routes. Changes: - Remove all client-side environment variable checks - Set wrenApiKey to dummy value 'server-proxy' - Add comments explaining API key is server-side only - Remove error logging for missing client-side key This fixes the console error: "Missing required environment variable: NEXT_PUBLIC_WREN_API_TOKEN"
This commit is contained in:
parent
7751976fc9
commit
5680dfa65f
@ -1,38 +1,21 @@
|
||||
interface Config {
|
||||
wrenApiKey: string;
|
||||
wrenApiKey: string; // Legacy field - now handled by server-side proxy routes
|
||||
isProduction: boolean;
|
||||
}
|
||||
|
||||
// Load environment variables - Next.js requires direct static references
|
||||
// First try window.env (for Docker), then fall back to process.env (for development)
|
||||
const getWrenApiKey = (): string => {
|
||||
// Check window.env for Docker deployment
|
||||
if (typeof window !== 'undefined' && (window as any).env?.WREN_API_TOKEN) {
|
||||
return (window as any).env.WREN_API_TOKEN;
|
||||
}
|
||||
|
||||
// Fall back to Next.js environment variable (must be direct reference for client-side)
|
||||
return process.env.NEXT_PUBLIC_WREN_API_TOKEN || '';
|
||||
};
|
||||
|
||||
const wrenApiKey = getWrenApiKey();
|
||||
|
||||
// Initialize config
|
||||
// NOTE: Wren API key is no longer needed client-side
|
||||
// All Wren API calls go through server-side proxy routes at /api/wren/*
|
||||
// which securely handle the API token on the server
|
||||
export const config: Config = {
|
||||
wrenApiKey: wrenApiKey || '',
|
||||
wrenApiKey: 'server-proxy', // Dummy value - actual key is server-side only
|
||||
isProduction: process.env.NODE_ENV === 'production'
|
||||
};
|
||||
|
||||
// Validate required environment variables
|
||||
if (!config.wrenApiKey) {
|
||||
console.error('Missing required environment variable: NEXT_PUBLIC_WREN_API_TOKEN');
|
||||
console.error('Current environment:', typeof window !== 'undefined' && (window as any)?.env ? JSON.stringify((window as any).env) : 'No window.env available');
|
||||
}
|
||||
|
||||
// Log config in development
|
||||
if (!config.isProduction) {
|
||||
console.log('Config:', {
|
||||
...config,
|
||||
wrenApiKey: config.wrenApiKey ? '[REDACTED]' : 'MISSING'
|
||||
isProduction: config.isProduction,
|
||||
wrenApiKey: '[SERVER-SIDE PROXY]'
|
||||
});
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user