FINAL FIX: Docker API URL resolution for internal service communication
- Fixed internal API calls in Docker environment to use port 3000 instead of 9000 - Added DOCKER_ENV detection to properly route internal fetch requests - Resolves ECONNREFUSED errors when APIs try to call each other within container - Trade validation now works correctly in Docker: 5 USD position validates properly - Successfully tested: amountUSD field properly passed through validation pipeline - Both development and Docker environments now fully functional
This commit is contained in:
@@ -7,10 +7,10 @@ export async function POST(request) {
|
||||
|
||||
console.log(`🔍 Validating trade: ${side} ${amount} ${symbol} (USD: ${amountUSD})`)
|
||||
|
||||
// Get the base URL from the request or use localhost for development
|
||||
// For Docker environment, use internal port 3000. For dev, use the host header
|
||||
const host = request.headers.get('host') || 'localhost:3000'
|
||||
const protocol = host.includes('localhost') ? 'http' : 'https'
|
||||
const baseUrl = `${protocol}://${host}`
|
||||
const isDocker = process.env.DOCKER_ENV === 'true'
|
||||
const baseUrl = isDocker ? 'http://localhost:3000' : `http://${host}`
|
||||
|
||||
// Fetch real wallet balance from the wallet API
|
||||
let walletBalance
|
||||
|
||||
Reference in New Issue
Block a user