From 118aa04d109e774d706f624b039377e20dee9f9b Mon Sep 17 00:00:00 2001 From: RainbowUnicorn7297 <67099591+RainbowUnicorn7297@users.noreply.github.com> Date: Thu, 9 Jun 2022 01:05:47 +0800 Subject: [PATCH] fix API server host to localhost --- prototype/build.bat | 2 +- prototype/proxy.py | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/prototype/build.bat b/prototype/build.bat index 572ef40..b07dd6f 100644 --- a/prototype/build.bat +++ b/prototype/build.bat @@ -1 +1 @@ -pyinstaller --clean -F main.spec \ No newline at end of file +pyinstaller --clean main.spec \ No newline at end of file diff --git a/prototype/proxy.py b/prototype/proxy.py index 6bb8a32..7c9100a 100644 --- a/prototype/proxy.py +++ b/prototype/proxy.py @@ -2,17 +2,19 @@ from ssl import SSLContext, PROTOCOL_TLS_SERVER from os import path import sys, requests +import urllib3 port = 443 api_port = 8443 +urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) + class ProxyHTTPRequestHandler(BaseHTTPRequestHandler): protocol_version = 'HTTP/1.1' close_connection = True def do_POST(self): - host = self.headers.get('Host') - host = host.split(':')[0] + ':' + str(api_port) + host = 'localhost:' + str(api_port) url = f'https://{host}{self.path}' content_len = int(self.headers.get('Content-Length')) req_body = self.rfile.read(content_len)