This commit is contained in:
+7
-15
@@ -1334,27 +1334,19 @@ def register_web_routes(app, dependencies):
|
|||||||
import os
|
import os
|
||||||
import socket
|
import socket
|
||||||
|
|
||||||
# Get request body
|
|
||||||
try:
|
|
||||||
body = await request.json()
|
|
||||||
except:
|
|
||||||
body = {}
|
|
||||||
|
|
||||||
# Get core container URL
|
# Get core container URL
|
||||||
core_host = os.environ.get("CORE_API_HOST", "nfoguard-core")
|
core_host = os.environ.get("CORE_API_HOST", "nfoguard-core")
|
||||||
core_port = os.environ.get("CORE_API_PORT", "8080")
|
core_port = os.environ.get("CORE_API_PORT", "8080")
|
||||||
|
|
||||||
|
# Forward query parameters from the request
|
||||||
|
query_string = str(request.url.query) if request.url.query else ""
|
||||||
core_url = f"http://{core_host}:{core_port}/manual/scan"
|
core_url = f"http://{core_host}:{core_port}/manual/scan"
|
||||||
|
if query_string:
|
||||||
|
core_url += f"?{query_string}"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Prepare request data
|
# Create request with timeout (no body needed for query parameters)
|
||||||
data = json.dumps(body).encode('utf-8')
|
req = urllib.request.Request(core_url, method='POST')
|
||||||
|
|
||||||
# Create request with timeout
|
|
||||||
req = urllib.request.Request(
|
|
||||||
core_url,
|
|
||||||
data=data,
|
|
||||||
headers={'Content-Type': 'application/json'}
|
|
||||||
)
|
|
||||||
|
|
||||||
# Make request with timeout
|
# Make request with timeout
|
||||||
with urllib.request.urlopen(req, timeout=30) as response:
|
with urllib.request.urlopen(req, timeout=30) as response:
|
||||||
|
|||||||
Reference in New Issue
Block a user