You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Laravel 6迁移后API的get()端点无法解析请求参数问题

Laravel 6 GET请求参数无法解析问题(Nginx环境)

迁移遗留服务器应用代码到新服务器后,除API的GET端点外其余功能均正常,该端点无法正确解析请求参数(已确认参数键名无误)。

测试代码与返回结果

最初测试代码

public function lst(Request $request) {
        $response = [];

        return response()->json($request);
}

修改后的测试代码(@silver建议)

public function lst(Request $request)
{
    $response = [];
    return response()->json(['all' => $request->all(), 'input' => $request->input('CodigoArmario'), 'request' => request('CodigoArmario') ] );
}

返回结果

{
"all": {
    "query_string": null
},
"input": null,
"request": null
}

应用环境与Nginx配置

  • PHP版本:7.4
  • Laravel版本:6

Nginx配置如下:

server {
        server_name serverwebsitename.com;
        root /var/www/serverwebsitename/public/;

        if ($host ~* ^www\.(.*)$ )
        {
                return 301 https://$1$request_uri;
        }

        add_header X-Frame-Options "SAMEORIGIN";
        add_header X-Content-Type-Options "nosniff";

        index index.html index.php;

        charset utf-8;

        location / {
                try_files $uri $uri/ /index.php?query_string;
        }

        location = /favicon.ico { access_log off; log_not_found off; }
        location = /robots.txt  { access_log off; log_not_found off; }

        error_page 404 /index.php;

        location ~ \.php$ {
                fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
                fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
                include fastcgi_params;
        }

        location ~ /\.(?!well-known).* {
                deny all;
        }

        listen [::]:443 ssl;
        listen 443 ssl;
        ssl_certificate /etc/letsencrypt/live/serverwebsitename.com/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/serverwebsitename.com/privkey.pem;
        include /etc/letsencrypt/options-ssl-nginx.conf;
        ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;

}

server {
        listen 80;
        listen [::]:80;
        server_name serverwebsitename.com www.serverwebsitename.com;

        return 301 https://$host$request_uri;
}

已排查情况

  • 本地使用PHP7.4+Apache的Docker镜像测试,GET端点功能正常
  • 将本地数据库部署到生产环境后,问题依旧存在
  • 删除vendor目录并重新安装Composer依赖,问题未解决

内容的提问来源于stack exchange,提问作者TAVARES

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.02 03:23:18