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:
mindesbunister
2025-07-28 01:19:37 +02:00
parent 236e2b0d31
commit abb8c8d7f1
4 changed files with 217 additions and 83 deletions

View File

@@ -243,7 +243,7 @@ class PositionConsolidator {
*/
static async cancelAllOrders() {
try {
const response = await fetch('http://localhost:9001/api/drift/cancel-all-orders', {
const response = await fetch('http://localhost:3000/api/drift/cancel-all-orders', {
method: 'POST',
headers: { 'Content-Type': 'application/json' }
});
@@ -262,7 +262,7 @@ class PositionConsolidator {
*/
static async placeConsolidatedOrder(orderParams) {
try {
const response = await fetch('http://localhost:9001/api/drift/place-order', {
const response = await fetch('http://localhost:3000/api/drift/place-order', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
@@ -297,7 +297,7 @@ class PositionConsolidator {
*/
static async getCurrentPosition() {
try {
const response = await fetch('http://localhost:9001/api/drift/positions');
const response = await fetch('http://localhost:3000/api/drift/positions');
const result = await response.json();
if (result.success && result.positions.length > 0) {