- Replace hardcoded localhost URLs with dynamic host detection from request headers - Supports both development (localhost:3001) and Docker (localhost:9000 -> 3000) environments - Uses host header to determine correct protocol and port for internal API calls - Updated execute-dex, validate, and orders APIs to use dynamic baseUrl - Ensures proper API communication in containerized environments
44 lines
1.3 KiB
JavaScript
44 lines
1.3 KiB
JavaScript
// Quick test to verify the trade validation fix
|
|
const testTradeValidation = async () => {
|
|
console.log('🧪 Testing trade validation with fixed amountUSD...')
|
|
|
|
// Use port 9000 for Docker or 3001 for local dev
|
|
const apiUrl = process.env.DOCKER_MODE ? 'http://localhost:9000' : 'http://localhost:3001'
|
|
|
|
const tradeData = {
|
|
symbol: 'USDCUSD',
|
|
side: 'BUY',
|
|
amount: 5,
|
|
amountUSD: 5, // This should be passed through correctly now
|
|
useRealDEX: false, // Use simulation for testing
|
|
tradingPair: 'USDCUSD/USDC'
|
|
}
|
|
|
|
console.log('🚀 Sending test trade to:', apiUrl)
|
|
console.log('🚀 Trade data:', tradeData)
|
|
|
|
try {
|
|
const response = await fetch(`${apiUrl}/api/trading/execute-dex`, {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify(tradeData)
|
|
})
|
|
|
|
const result = await response.json()
|
|
|
|
console.log('📊 Response status:', response.status)
|
|
console.log('📊 Response body:', result)
|
|
|
|
if (response.ok) {
|
|
console.log('✅ Trade validation fix is working!')
|
|
} else {
|
|
console.log('❌ Trade validation still has issues:', result.message)
|
|
}
|
|
|
|
} catch (error) {
|
|
console.error('❌ Test failed:', error)
|
|
}
|
|
}
|
|
|
|
testTradeValidation()
|