small container

This commit is contained in:
JurajKubrican
2024-10-29 08:11:16 +01:00
parent ebd579056a
commit 9a462f06b8
7 changed files with 50 additions and 12 deletions

30
index.php Normal file
View File

@@ -0,0 +1,30 @@
<?php
// URL of the backend server
$backend_url = "http://localhost:5000" . $_SERVER['REQUEST_URI'];
// Initialize cURL
$ch = curl_init($backend_url);
// Forward the request method (GET, POST, etc.) and headers
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $_SERVER['REQUEST_METHOD']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Forward headers
foreach (getallheaders() as $header => $value) {
curl_setopt($ch, CURLOPT_HTTPHEADER, ["$header: $value"]);
}
// Handle POST data if it exists
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
curl_setopt($ch, CURLOPT_POSTFIELDS, file_get_contents('php://input'));
}
// Execute the request
$response = curl_exec($ch);
// Forward the response back to the client
http_response_code(curl_getinfo($ch, CURLINFO_HTTP_CODE));
echo $response;
// Close cURL
curl_close($ch);