From a2d7033ccae8c1166bf01ce1b7079d8bad4bcd16 Mon Sep 17 00:00:00 2001 From: spman Date: Fri, 20 Dec 2024 20:47:19 +0700 Subject: [PATCH 1/2] Update Application.php Fix Request path_info $request->server['path_info'] is not value, this is $server['path_info'] --- src/Application.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Application.php b/src/Application.php index 736c99d..69e3c46 100644 --- a/src/Application.php +++ b/src/Application.php @@ -81,10 +81,10 @@ public function swoole(Request $request, Response $response) ->withCookie($_COOKIE) ->withInput($request->rawContent()) ->withFiles($_FILES) - ->setBaseUrl($request->server['request_uri']) - ->setUrl($request->server['request_uri'] . (!empty($request->server['query_string']) ? '&' . $request->server['query_string'] : '')) - ->setHost($request->header['host']) - ->setPathinfo(ltrim($request->server['path_info'], '/')); + ->setBaseUrl($server['request_uri']) + ->setUrl($server['request_uri'] . (!empty($server['query_string']) ? '&' . $server['query_string'] : '')) + ->setHost($header['host']) + ->setPathinfo(ltrim($server['path_info'], '/')); // 更新请求对象实例 $this->route->setRequest($this->request); From d4b23af696455fdeeff79f44cb063165fcb040f8 Mon Sep 17 00:00:00 2001 From: spman Date: Sat, 21 Dec 2024 00:49:23 +0700 Subject: [PATCH 2/2] Update Application.php Fix Request path_info Update Application.php Fix Request path_info And Nginx --- src/Application.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Application.php b/src/Application.php index 69e3c46..94e02b2 100644 --- a/src/Application.php +++ b/src/Application.php @@ -71,6 +71,11 @@ public function swoole(Request $request, Response $response) $server['path_info'] = $_GET[$this->config->get('var_pathinfo')]; } + // Nginx兼容: proxy_set_header SERVER_PORT $server_port; + if(isset($header['server_port'])) { + $server['server_port'] = $header['server_port']; + } + $_SERVER = array_change_key_case($server, CASE_UPPER); // 重新实例化请求对象 处理swoole请求数据