English 中文(简体)
thinkphp tp Request.php 获取host问题 否则vue,跨域的时候会报404错误
  • 时间:2023-06-08 17:11:01

thinkphp tp Request.php 获取host问题


项目/thinkphp/pbrary/think/Request.php 

原来是


        if (!$this->host) {

            $this->host = $this->server('HTTP_X_REAL_HOST') ?: $this->server('HTTP_X_FORWARDED_HOST') ?: $this->server('HTTP_HOST');

        }

需要改成


        if (!$this->host) {

            $this->host = $this->server('HTTP_X_REAL_HOST') ?: $this->server('HTTP_HOST');

        }

否则vue,跨域的时候会报404错误