[英]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.