簡體   English   中英

將流明從5.3升級到5.4會中斷路由-需要附加前綴

[英]Upgrading Lumen from 5.3 to 5.4 breaks routing - requires additional prefix

我正在按照升級指南將Lumen應用程序升級到最新版本。 升級到5.4將以以下方式中斷路由。

/oauth/test處有一條路由。

現在,結果為404(在5.3上正常): http://testcase.local/oauth/test

如果對路徑進行雙重嵌套,則可以進行以下操作:

http://testcase.local/oauth/oauth/test

稍微復雜一點,因為應用程序的前端(單頁JS)位於apache后面,並且基於后端的路由被符號鏈接。但是,apache的配置正確(FollowSymLinks),並且該配置在5.3中工作正常。

路由在php artisan route:list正確php artisan route:list

5.4中有哪些更改可以解決此問題,我該如何解決?

編輯:原因是對流明的承諾

因此,在此用例中,symfony / http-foundation處理基於symlink的路徑的方式有所中斷。

解決方法是更改​​以下方法的邏輯:

class Application extends \Laravel\Lumen\Application
{
    /**
     * This override fixes our routing problem
     * https://stackoverflow.com/questions/49048199/upgrading-lumen-from-5-3-to-5-4-breaks-routing-requires-additional-prefix
     *
     * Parse the incoming request and return the method and path info.
     *
     * @param  \Symfony\Component\HttpFoundation\Request|null  $request
     * @return array
     */
    protected function parseIncomingRequest($request)
    {
        if (! $request) {
            $request = Request::capture();
        }

        $this->instance(Request::class, $this->prepareRequest($request));

        // need the base url as well as the pathinfo when coming from symlinks
        return [$request->getMethod(), '/'.trim($request->getBaseUrl() . $request->getPathInfo(), '/')];
    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM