From 30692fe0db2d614308db897118858e4436626316 Mon Sep 17 00:00:00 2001 From: Shaun Orssaud <72015533+Shorssaud@users.noreply.github.com> Date: Wed, 1 Nov 2023 18:11:34 +0900 Subject: [PATCH] Python API works now --- api/api.py | 9 +++++++++ deployment/nginx.default.conf | 4 ---- docker-compose.yml | 3 ++- frontend/.env | 2 +- frontend/src/pages/debug/DebugPage.tsx | 14 +++++--------- 5 files changed, 17 insertions(+), 15 deletions(-) diff --git a/api/api.py b/api/api.py index e58db6a..4e4a668 100644 --- a/api/api.py +++ b/api/api.py @@ -10,6 +10,15 @@ CORS(app) def root(): return jsonify({'message': 'Welcome to the API!'}) +@app.route('/debug') +def debug(): + base_url = request.headers.get('Base-Url') + response = requests.get( + f'{base_url}/api/codex/v1/debug/info' + ) + print(response.status_code) + print(response.text) + return response.text @app.route('/upload', methods=['POST']) def upload(): diff --git a/deployment/nginx.default.conf b/deployment/nginx.default.conf index abe98f4..943a687 100644 --- a/deployment/nginx.default.conf +++ b/deployment/nginx.default.conf @@ -15,8 +15,4 @@ server { expires 1y; add_header Cache-Control "public"; } - - location /uploads { - proxy_pass http://localhost:5000; - } } \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 86082d7..af0e435 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,7 +4,8 @@ services: context: . dockerfile: Dockerfile.api image: codex-frontend-api - network_mode: "host" + ports: + - "5000:5000" client: build: context: . diff --git a/frontend/.env b/frontend/.env index 553b76f..9fd53b7 100644 --- a/frontend/.env +++ b/frontend/.env @@ -1 +1 @@ -REACT_APP_CODEX_URL=http://localhost:8080 +REACT_APP_CODEX_URL=http://host.docker.internal:8080 diff --git a/frontend/src/pages/debug/DebugPage.tsx b/frontend/src/pages/debug/DebugPage.tsx index 0863b8a..a719090 100644 --- a/frontend/src/pages/debug/DebugPage.tsx +++ b/frontend/src/pages/debug/DebugPage.tsx @@ -8,6 +8,7 @@ import { import NodeInfoItemComponent from "../../components/nodeInfoItem/NodeInfoItemComponent"; import Header from "../../components/layout/partials/Header"; import { useDexyStore } from "../../store"; +import constants from "../../util/Constants"; function DebugPage() { const { nodeInfo } = useDexyStore(); @@ -15,20 +16,15 @@ function DebugPage() { const [statusInfo, setStatusInfo] = React.useState< DebugNodeInfoModel | undefined >(); - useEffect(() => { axios .get( - `${ - nodeInfo.nodeToConnectTo || nodeInfo.baseUrl - }/api/codex/v1/debug/info`, + `${constants.testApiBaseUrl}/debug`, { headers: - (nodeInfo.auth !== null && { - Authorization: - (nodeInfo.auth && "Basic " + btoa(nodeInfo.auth)) || "", - }) || - {}, + ({ + "Base-Url": nodeInfo.baseUrl, + }), } ) .then((response) => {