fix: resolve container networking issues for automation system
- Fixed internal API URLs from localhost:9001 to localhost:3000 in automation core files - Updated lib/simple-automation.js: Fixed 5 baseUrl references for internal container calls - Updated app/api/drift/consolidate-position/route.js: Fixed positions API fetch URL - Updated app/api/drift/scale-position/route.js: Fixed 2 internal API calls (positions and orders) - Updated lib/position-consolidator.js: Fixed 3 internal API calls (cancel-all-orders, place-order, positions) This resolves 'Network Error' and 'fetch failed' issues that prevented automation cycles from executing properly within Docker container environment. Root cause: Automation was making fetch calls to external port (9001) from within container instead of internal port (3000), causing connection failures. Result: Automation cycles now execute successfully with proper internal API connectivity.
This commit is contained in:
@@ -10,7 +10,7 @@ export async function POST(request) {
|
||||
console.log(`AI Analysis: ${analysis ? 'Provided - Using AI optimal levels' : 'Not provided - Using adaptive levels'}`);
|
||||
|
||||
// Get current position data
|
||||
const positionsResponse = await fetch('http://localhost:9001/api/drift/positions');
|
||||
const positionsResponse = await fetch('http://localhost:3000/api/drift/positions');
|
||||
const positionsData = await positionsResponse.json();
|
||||
|
||||
if (!positionsData.success || !positionsData.positions.length) {
|
||||
|
||||
@@ -29,7 +29,7 @@ export async function POST(request) {
|
||||
console.log(`💰 Adding $${dcaAmount} to existing position`);
|
||||
|
||||
// 1. Get current position
|
||||
const positionResponse = await fetch(`${process.env.INTERNAL_API_URL || 'http://localhost:9001'}/api/drift/positions`);
|
||||
const positionResponse = await fetch(`${process.env.INTERNAL_API_URL || 'http://localhost:3000'}/api/drift/positions`);
|
||||
const positionData = await positionResponse.json();
|
||||
|
||||
if (!positionData.success || positionData.positions.length === 0) {
|
||||
@@ -86,7 +86,7 @@ export async function POST(request) {
|
||||
// 5. Cancel existing stop loss and take profit orders
|
||||
console.log('🧹 Canceling existing SL/TP orders...');
|
||||
try {
|
||||
const ordersResponse = await fetch(`${process.env.INTERNAL_API_URL || 'http://localhost:9001'}/api/drift/orders`);
|
||||
const ordersResponse = await fetch(`${process.env.INTERNAL_API_URL || 'http://localhost:3000'}/api/drift/orders`);
|
||||
const ordersData = await ordersResponse.json();
|
||||
|
||||
if (ordersData.success && ordersData.orders.length > 0) {
|
||||
|
||||
Reference in New Issue
Block a user