import { NextRequest, NextResponse } from 'next/server' import { tradingViewAutomation } from '../../../lib/tradingview-automation' export async function POST(req: NextRequest) { try { console.log('🧪 Testing manual CAPTCHA interaction...') // Initialize browser with manual CAPTCHA support await tradingViewAutomation.init() // Try a login that will likely trigger CAPTCHA const loginResult = await tradingViewAutomation.smartLogin() return NextResponse.json({ success: loginResult, message: loginResult ? 'Login successful!' : 'Login failed or CAPTCHA interaction required', timestamp: new Date().toISOString() }) } catch (error: any) { console.error('Manual CAPTCHA test failed:', error) return NextResponse.json({ error: error.message, timestamp: new Date().toISOString() }, { status: 500 }) } } export async function GET(req: NextRequest) { return NextResponse.json({ message: 'Manual CAPTCHA test endpoint', instructions: [ '1. Send a POST request to this endpoint to trigger login with manual CAPTCHA support', '2. If CAPTCHA is detected, a browser window will appear (non-headless mode)', '3. Manually click the "I am not a robot" checkbox', '4. Complete any additional challenges', '5. The automation will continue once CAPTCHA is solved' ], environment: { allowManualCaptcha: process.env.ALLOW_MANUAL_CAPTCHA === 'true', display: process.env.DISPLAY } }) }