鍍金池/ 問答/PHP/ laravel 線上環(huán)境 api接口,出錯信息全通過json暴露出來了,如何屏蔽

laravel 線上環(huán)境 api接口,出錯信息全通過json暴露出來了,如何屏蔽

laravel 線上環(huán)境 api接口,出錯信息全通過json暴露出來了,如何屏蔽

.env 文件設(shè)置如下
APP_ENV=production
APP_DEBUG=false

{
    "error":500,
    "data":"Undefined index: list_code",
    "trace":[
        {
            "file":"/data/www.baidu.com/app/Http/Controllers/API/WWWController.php",
            "line":142,
            "function":"handleError",
            "class":"Illuminate\Foundation\Bootstrap\HandleExceptions",
            "type":"->",
            "args":[
                8,
                "Undefined index: xm_list_code",
                "/data/www.baidu.com/app/Http/Controllers/API/WWWController.php",
                142,
                {
                    "request":{
                        "attributes":{

                        },
                        "request":{

                        },
                        "query":{

                        },
                        "server":{

                        },
                        "files":{

                        },
                        "cookies":{

                        },
                        "headers":{

                        }
                    },
                    "params":{

                    },
                    "result":{
                        "resultCode":0,
                        "resultMessage":"successful"
                    }
                }
            ]
        },
        {
            "function":"loanSuccess",
            "class":"App\Http\Controllers\API\WWWController",
            "type":"->",
            "args":[
                {
                    "attributes":{

                    },
                    "request":{

                    },
                    "query":{

                    },
                    "server":{

                    },
                    "files":{

                    },
                    "cookies":{

                    },
                    "headers":{

                    }
                }
            ]
        },
        {
            "file":"/data/www.baidu.com/bootstrap/cache/compiled.php",
            "line":9425,
            "function":"call_user_func_array",
            "args":[
                [
                    {

                    },
                    "loanSuccess"
                ],
                [
                    {
                        "attributes":{

                        },
                        "request":{

                        },
                        "query":{

                        },
                        "server":{

                        },
                        "files":{

                        },
                        "cookies":{

                        },
                        "headers":{

                        }
                    }
                ]
            ]
        },
        {
            "file":"/data/www.baidu.com/bootstrap/cache/compiled.php",
            "line":9487,
            "function":"callAction",
            "class":"Illuminate\Routing\Controller",
            "type":"->",
            "args":[
                "loanSuccess",
                [
                    {
                        "attributes":{

                        },
                        "request":{

                        },
                        "query":{

                        },
                        "server":{

                        },
                        "files":{

                        },
                        "cookies":{

                        },
                        "headers":{

                        }
                    }
                ]
            ]
        },
        {
            "file":"/data/www.baidu.com/bootstrap/cache/compiled.php",
            "line":9467,
            "function":"call",
            "class":"Illuminate\Routing\ControllerDispatcher",
            "type":"->",
            "args":[
                {

                },
                {

                },
                "loanSuccess"
            ]
        },
        {
            "function":"Illuminate\Routing\{closure}",
            "class":"Illuminate\Routing\ControllerDispatcher",
            "type":"->",
            "args":[
                {
                    "attributes":{

                    },
                    "request":{

                    },
                    "query":{

                    },
                    "server":{

                    },
                    "files":{

                    },
                    "cookies":{

                    },
                    "headers":{

                    }
                }
            ]
        },
        {
            "file":"/data/www.baidu.com/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php",
            "line":52,
            "function":"call_user_func",
            "args":[
                {

                },
                {
                    "attributes":{

                    },
                    "request":{

                    },
                    "query":{

                    },
                    "server":{

                    },
                    "files":{

                    },
                    "cookies":{

                    },
                    "headers":{

                    }
                }
            ]
        },
        {
            "function":"Illuminate\Routing\{closure}",
            "class":"Illuminate\Routing\Pipeline",
            "type":"->",
            "args":[
                {
                    "attributes":{

                    },
                    "request":{

                    },
                    "query":{

                    },
                    "server":{

                    },
                    "files":{

                    },
                    "cookies":{

                    },
                    "headers":{

                    }
                }
            ]
        },
        {
            "file":"/data/www.baidu.com/bootstrap/cache/compiled.php",
            "line":9950,
            "function":"call_user_func",
            "args":[
                {

                },
                {
                    "attributes":{

                    },
                    "request":{

                    },
                    "query":{

                    },
                    "server":{

                    },
                    "files":{

                    },
                    "cookies":{

                    },
                    "headers":{

                    }
                }
            ]
        },
        {
            "file":"/data/www.baidu.com/bootstrap/cache/compiled.php",
            "line":9468,
            "function":"then",
            "class":"Illuminate\Pipeline\Pipeline",
            "type":"->",
            "args":[
                {

                }
            ]
        },
        {
            "file":"/data/www.baidu.com/bootstrap/cache/compiled.php",
            "line":9455,
            "function":"callWithinStack",
            "class":"Illuminate\Routing\ControllerDispatcher",
            "type":"->",
            "args":[
                {

                },
                {

                },
                {
                    "attributes":{

                    },
                    "request":{

                    },
                    "query":{

                    },
                    "server":{

                    },
                    "files":{

                    },
                    "cookies":{

                    },
                    "headers":{

                    }
                },
                "loanSuccess"
            ]
        },
        {
            "file":"/data/www.baidu.com/bootstrap/cache/compiled.php",
            "line":8525,
            "function":"dispatch",
            "class":"Illuminate\Routing\ControllerDispatcher",
            "type":"->",
            "args":[
                {

                },
                {
                    "attributes":{

                    },
                    "request":{

                    },
                    "query":{

                    },
                    "server":{

                    },
                    "files":{

                    },
                    "cookies":{

                    },
                    "headers":{

                    }
                },
                "App\Http\Controllers\API\WWWController",
                "loanSuccess"
            ]
        },
        {
            "file":"/data/www.baidu.com/bootstrap/cache/compiled.php",
            "line":8512,
            "function":"runController",
            "class":"Illuminate\Routing\Route",
            "type":"->",
            "args":[
                {
                    "attributes":{

                    },
                    "request":{

                    },
                    "query":{

                    },
                    "server":{

                    },
                    "files":{

                    },
                    "cookies":{

                    },
                    "headers":{

                    }
                }
            ]
        },
        {
            "file":"/data/www.baidu.com/bootstrap/cache/compiled.php",
            "line":8226,
            "function":"run",
            "class":"Illuminate\Routing\Route",
            "type":"->",
            "args":[
                {
                    "attributes":{

                    },
                    "request":{

                    },
                    "query":{

                    },
                    "server":{

                    },
                    "files":{

                    },
                    "cookies":{

                    },
                    "headers":{

                    }
                }
            ]
        },
        {
            "function":"Illuminate\Routing\{closure}",
            "class":"Illuminate\Routing\Router",
            "type":"->",
            "args":[
                {
                    "attributes":{

                    },
                    "request":{

                    },
                    "query":{

                    },
                    "server":{

                    },
                    "files":{

                    },
                    "cookies":{

                    },
                    "headers":{

                    }
                }
            ]
        },
        {
            "file":"/data/www.baidu.com/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php",
            "line":52,
            "function":"call_user_func",
            "args":[
                {

                },
                {
                    "attributes":{

                    },
                    "request":{

                    },
                    "query":{

                    },
                    "server":{

                    },
                    "files":{

                    },
                    "cookies":{

                    },
                    "headers":{

                    }
                }
            ]
        },
        {
            "file":"/data/www.baidu.com/vendor/laravel/framework/src/Illuminate/Routing/Middleware/ThrottleRequests.php",
            "line":48,
            "function":"Illuminate\Routing\{closure}",
            "class":"Illuminate\Routing\Pipeline",
            "type":"->",
            "args":[
                {
                    "attributes":{

                    },
                    "request":{

                    },
                    "query":{

                    },
                    "server":{

                    },
                    "files":{

                    },
                    "cookies":{

                    },
                    "headers":{

                    }
                }
            ]
        },
        {
            "function":"handle",
            "class":"Illuminate\Routing\Middleware\ThrottleRequests",
            "type":"->",
            "args":[
                {
                    "attributes":{

                    },
                    "request":{

                    },
                    "query":{

                    },
                    "server":{

                    },
                    "files":{

                    },
                    "cookies":{

                    },
                    "headers":{

                    }
                },
                {

                },
                "60",
                "1"
            ]
        },
        {
            "file":"/data/www.baidu.com/bootstrap/cache/compiled.php",
            "line":9965,
            "function":"call_user_func_array",
            "args":[
                [
                    {

                    },
                    "handle"
                ],
                [
                    {
                        "attributes":{

                        },
                        "request":{

                        },
                        "query":{

                        },
                        "server":{

                        },
                        "files":{

                        },
                        "cookies":{

                        },
                        "headers":{

                        }
                    },
                    {

                    },
                    "60",
                    "1"
                ]
            ]
        },
        {
            "function":"Illuminate\Pipeline\{closure}",
            "class":"Illuminate\Pipeline\Pipeline",
            "type":"->",
            "args":[
                {
                    "attributes":{

                    },
                    "request":{

                    },
                    "query":{

                    },
                    "server":{

                    },
                    "files":{

                    },
                    "cookies":{

                    },
                    "headers":{

                    }
                }
            ]
        },
        {
            "file":"/data/www.baidu.com/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php",
            "line":32,
            "function":"call_user_func",
            "args":[
                {

                },
                {
                    "attributes":{

                    },
                    "request":{

                    },
                    "query":{

                    },
                    "server":{

                    },
                    "files":{

                    },
                    "cookies":{

                    },
                    "headers":{

                    }
                }
            ]
        },
        {
            "file":"/data/www.baidu.com/app/Http/Middleware/API.php",
            "line":24,
            "function":"Illuminate\Routing\{closure}",
            "class":"Illuminate\Routing\Pipeline",
            "type":"->",
            "args":[
                {
                    "attributes":{

                    },
                    "request":{

                    },
                    "query":{

                    },
                    "server":{

                    },
                    "files":{

                    },
                    "cookies":{

                    },
                    "headers":{

                    }
                }
            ]
        },
        {
            "function":"handle",
            "class":"App\Http\Middleware\API",
            "type":"->",
            "args":[
                {
                    "attributes":{

                    },
                    "request":{

                    },
                    "query":{

                    },
                    "server":{

                    },
                    "files":{

                    },
                    "cookies":{

                    },
                    "headers":{

                    }
                },
                {

                }
            ]
        },
        {
            "file":"/data/www.baidu.com/bootstrap/cache/compiled.php",
            "line":9965,
            "function":"call_user_func_array",
            "args":[
                [
                    {

                    },
                    "handle"
                ],
                [
                    {
                        "attributes":{

                        },
                        "request":{

                        },
                        "query":{

                        },
                        "server":{

                        },
                        "files":{

                        },
                        "cookies":{

                        },
                        "headers":{

                        }
                    },
                    {

                    }
                ]
            ]
        },
        {
            "function":"Illuminate\Pipeline\{closure}",
            "class":"Illuminate\Pipeline\Pipeline",
            "type":"->",
            "args":[
                {
                    "attributes":{

                    },
                    "request":{

                    },
                    "query":{

                    },
                    "server":{

                    },
                    "files":{

                    },
                    "cookies":{

                    },
                    "headers":{

                    }
                }
            ]
        },
        {
            "file":"/data/www.baidu.com/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php",
            "line":32,
            "function":"call_user_func",
            "args":[
                {

                },
                {
                    "attributes":{

                    },
                    "request":{

                    },
                    "query":{

                    },
                    "server":{

                    },
                    "files":{

                    },
                    "cookies":{

                    },
                    "headers":{

                    }
                }
            ]
        },
        {
            "file":"/data/www.baidu.com/app/Http/Middleware/LocaleMiddleware.php",
            "line":48,
            "function":"Illuminate\Routing\{closure}",
            "class":"Illuminate\Routing\Pipeline",
            "type":"->",
            "args":[
                {
                    "attributes":{

                    },
                    "request":{

                    },
                    "query":{

                    },
                    "server":{

                    },
                    "files":{

                    },
                    "cookies":{

                    },
                    "headers":{

                    }
                }
            ]
        },
        {
            "function":"handle",
            "class":"App\Http\Middleware\LocaleMiddleware",
            "type":"->",
            "args":[
                {
                    "attributes":{

                    },
                    "request":{

                    },
                    "query":{

                    },
                    "server":{

                    },
                    "files":{

                    },
                    "cookies":{

                    },
                    "headers":{

                    }
                },
                {

                }
            ]
        },
        {
            "file":"/data/www.baidu.com/bootstrap/cache/compiled.php",
            "line":9965,
            "function":"call_user_func_array",
            "args":[
                [
                    {

                    },
                    "handle"
                ],
                [
                    {
                        "attributes":{

                        },
                        "request":{

                        },
                        "query":{

                        },
                        "server":{

                        },
                        "files":{

                        },
                        "cookies":{

                        },
                        "headers":{

                        }
                    },
                    {

                    }
                ]
            ]
        },
        {
            "function":"Illuminate\Pipeline\{closure}",
            "class":"Illuminate\Pipeline\Pipeline",
            "type":"->",
            "args":[
                {
                    "attributes":{

                    },
                    "request":{

                    },
                    "query":{

                    },
                    "server":{

                    },
                    "files":{

                    },
                    "cookies":{

                    },
                    "headers":{

                    }
                }
            ]
        },
        {
            "file":"/data/www.baidu.com/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php",
            "line":32,
            "function":"call_user_func",
            "args":[
                {

                },
                {
                    "attributes":{

                    },
                    "request":{

                    },
                    "query":{

                    },
                    "server":{

                    },
                    "files":{

                    },
                    "cookies":{

                    },
                    "headers":{

                    }
                }
            ]
        },
        {
            "file":"/data/www.baidu.com/bootstrap/cache/compiled.php",
            "line":11956,
            "function":"Illuminate\Routing\{closure}",
            "class":"Illuminate\Routing\Pipeline",
            "type":"->",
            "args":[
                {
                    "attributes":{

                    },
                    "request":{

                    },
                    "query":{

                    },
                    "server":{

                    },
                    "files":{

                    },
                    "cookies":{

                    },
                    "headers":{

                    }
                }
            ]
        },
        {
            "function":"handle",
            "class":"Illuminate\Session\Middleware\StartSession",
            "type":"->",
            "args":[
                {
                    "attributes":{

                    },
                    "request":{

                    },
                    "query":{

                    },
                    "server":{

                    },
                    "files":{

                    },
                    "cookies":{

                    },
                    "headers":{

                    }
                },
                {

                }
            ]
        },
        {
            "file":"/data/www.baidu.com/bootstrap/cache/compiled.php",
            "line":9965,
            "function":"call_user_func_array",
            "args":[
                [
                    {

                    },
                    "handle"
                ],
                [
                    {
                        "attributes":{

                        },
                        "request":{

                        },
                        "query":{

                        },
                        "server":{

                        },
                        "files":{

                        },
                        "cookies":{

                        },
                        "headers":{

                        }
                    },
                    {

                    }
                ]
            ]
        },
        {
            "function":"Illuminate\Pipeline\{closure}",
            "class":"Illuminate\Pipeline\Pipeline",
            "type":"->",
            "args":[
                {
                    "attributes":{

                    },
                    "request":{

                    },
                    "query":{

                    },
                    "server":{

                    },
                    "files":{

                    },
                    "cookies":{

                    },
                    "headers":{

                    }
                }
            ]
        },
        {
            "file":"/data/www.baidu.com/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php",
            "line":32,
            "function":"call_user_func",
            "args":[
                {

                },
                {
                    "attributes":{

                    },
                    "request":{

                    },
                    "query":{

                    },
                    "server":{

                    },
                    "files":{

                    },
                    "cookies":{

                    },
                    "headers":{

                    }
                }
            ]
        },
        {
            "file":"/data/www.baidu.com/bootstrap/cache/compiled.php",
            "line":13202,
            "function":"Illuminate\Routing\{closure}",
            "class":"Illuminate\Routing\Pipeline",
            "type":"->",
            "args":[
                {
                    "attributes":{

                    },
                    "request":{

                    },
                    "query":{

                    },
                    "server":{

                    },
                    "files":{

                    },
                    "cookies":{

                    },
                    "headers":{

                    }
                }
            ]
        },
        {
            "function":"handle",
            "class":"Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse",
            "type":"->",
            "args":[
                {
                    "attributes":{

                    },
                    "request":{

                    },
                    "query":{

                    },
                    "server":{

                    },
                    "files":{

                    },
                    "cookies":{

                    },
                    "headers":{

                    }
                },
                {

                }
            ]
        },
        {
            "file":"/data/www.baidu.com/bootstrap/cache/compiled.php",
            "line":9965,
            "function":"call_user_func_array",
            "args":[
                [
                    {

                    },
                    "handle"
                ],
                [
                    {
                        "attributes":{

                        },
                        "request":{

                        },
                        "query":{

                        },
                        "server":{

                        },
                        "files":{

                        },
                        "cookies":{

                        },
                        "headers":{

                        }
                    },
                    {

                    }
                ]
            ]
        },
        {
            "function":"Illuminate\Pipeline\{closure}",
            "class":"Illuminate\Pipeline\Pipeline",
            "type":"->",
            "args":[
                {
                    "attributes":{

                    },
                    "request":{

                    },
                    "query":{

                    },
                    "server":{

                    },
                    "files":{

                    },
                    "cookies":{

                    },
                    "headers":{

                    }
                }
            ]
        },
        {
            "file":"/data/www.baidu.com/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php",
            "line":32,
            "function":"call_user_func",
            "args":[
                {

                },
                {
                    "attributes":{

                    },
                    "request":{

                    },
                    "query":{

                    },
                    "server":{

                    },
                    "files":{

                    },
                    "cookies":{

                    },
                    "headers":{

                    }
                }
            ]
        },
        {
            "file":"/data/www.baidu.com/bootstrap/cache/compiled.php",
            "line":13139,
            "function":"Illuminate\Routing\{closure}",
            "class":"Illuminate\Routing\Pipeline",
            "type":"->",
            "args":[
                {
                    "attributes":{

                    },
                    "request":{

                    },
                    "query":{

                    },
                    "server":{

                    },
                    "files":{

                    },
                    "cookies":{

                    },
                    "headers":{

                    }
                }
            ]
        },
        {
            "function":"handle",
            "class":"Illuminate\Cookie\Middleware\EncryptCookies",
            "type":"->",
            "args":[
                {
                    "attributes":{

                    },
                    "request":{

                    },
                    "query":{

                    },
                    "server":{

                    },
                    "files":{

                    },
                    "cookies":{

                    },
                    "headers":{

                    }
                },
                {

                }
            ]
        },
        {
            "file":"/data/www.baidu.com/bootstrap/cache/compiled.php",
            "line":9965,
            "function":"call_user_func_array",
            "args":[
                [
                    {

                    },
                    "handle"
                ],
                [
                    {
                        "attributes":{

                        },
                        "request":{

                        },
                        "query":{

                        },
                        "server":{

                        },
                        "files":{

                        },
                        "cookies":{

                        },
                        "headers":{

                        }
                    },
                    {

                    }
                ]
            ]
        },
        {
            "function":"Illuminate\Pipeline\{closure}",
            "class":"Illuminate\Pipeline\Pipeline",
            "type":"->",
            "args":[
                {
                    "attributes":{

                    },
                    "request":{

                    },
                    "query":{

                    },
                    "server":{

                    },
                    "files":{

                    },
                    "cookies":{

                    },
                    "headers":{

                    }
                }
            ]
        },
        {
            "file":"/data/www.baidu.com/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php",
            "line":32,
            "function":"call_user_func",
            "args":[
                {

                },
                {
                    "attributes":{

                    },
                    "request":{

                    },
                    "query":{

                    },
                    "server":{

                    },
                    "files":{

                    },
                    "cookies":{

                    },
                    "headers":{

                    }
                }
            ]
        },
        {
            "function":"Illuminate\Routing\{closure}",
            "class":"Il
回答
編輯回答
念初

php.ini

display_errors = Off;

2017年2月6日 04:46
編輯回答
護她命

try...catch 捕獲報錯信息,把錯誤信息記錄到日志中。api吐出的可以是自定的錯誤信息

2018年9月9日 03:16
編輯回答
傻叼

先說一點,凡是上線的項目,請務(wù)必

# .env 文件
APP_DEBUG=false
2017年10月7日 17:57
編輯回答
淺時光

如果你是用的 dingo/api 請再看下 API_DEBUG=false

2018年2月27日 15:19