diff --git a/app/api/mail/route.ts b/app/api/mail/route.ts index 34550a1..9bfb57a 100644 --- a/app/api/mail/route.ts +++ b/app/api/mail/route.ts @@ -54,30 +54,21 @@ interface ImapConfig { function getStoredCredentials(): StoredCredentials | null { if (typeof window === 'undefined') { - // Server-side - const email = process.env.IMAP_USER; - const password = process.env.IMAP_PASSWORD; - const host = process.env.IMAP_HOST; - const port = process.env.IMAP_PORT ? parseInt(process.env.IMAP_PORT) : 993; - - if (!email || !password || !host) { - return null; - } - - return { email, password, host, port }; - } else { - // Client-side - const stored = localStorage.getItem('imapCredentials'); - if (!stored) return null; - - const credentials = JSON.parse(stored); - return { - email: credentials.email, - password: credentials.password, - host: credentials.host, - port: credentials.port - }; + // Server-side - we should never get here in a client-side request + return null; } + + // Client-side + const stored = localStorage.getItem('imapCredentials'); + if (!stored) return null; + + const credentials = JSON.parse(stored); + return { + email: credentials.email, + password: credentials.password, + host: credentials.host, + port: credentials.port + }; } export async function GET() { diff --git a/app/api/mail/test-connection/route.ts b/app/api/mail/test-connection/route.ts index d79afb2..ed6de50 100644 --- a/app/api/mail/test-connection/route.ts +++ b/app/api/mail/test-connection/route.ts @@ -25,7 +25,8 @@ export async function POST(request: Request) { console.log('Testing IMAP connection with config:', { ...imapConfig, - password: '***' + password: '***', + email }); const imap = new Imap(imapConfig);