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

Laravel中访问带参数的路由(/storage/decode/hello)出现403 Forbidden错误的问题求助

Laravel中访问带参数的路由(/storage/decode/hello)出现403 Forbidden错误的问题求助

大家好,我碰到一个Laravel路由相关的问题,想请各位帮忙分析下:

当我访问URI '/storage/decode/hello' 时,页面会显示403错误,但访问 '/storage/decode' 这个URI时,代码却能完全正常运行。

我当前使用的路由代码如下:

Route::prefix('storage')->match(['GET', 'POST'], '{any?}', function (Request $request) {

    $requestedUri       = $request->getRequestUri();
    $requestedUri_array = explode('/', $requestedUri);
    $task               = $requestedUri_array[2];

    if ($request->isMethod('get')) {

        if ($task == 'decode') {
            if (! isset($requestedUri_array[3])) {
                return "Bro you are in wrong place.";
            }

            return "Yes bro right place to be";
        }

    }

    if ($request->isMethod('post')) {

        if ($task == 'encode') {
            if (! isset($requestedUri_array[3])) {
                dd(['success' => 'false', 'message' => 'Please provide valid data to store']);
            }
            $encryptedVal = encrypt($requestedUri_array[3]);
            dd($encryptedVal);
        } else {
            dd('Invalid URL');
        }

    }

});

麻烦各位帮忙看看问题出在哪,或者给点解决思路,谢谢啦!

备注:内容来源于stack exchange,提问作者Diwash Mainali

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.15 10:14:50