Laravel 7: 캐시 경로 오류
https://mydomain.com/aliasdomain
, generally, this has been supported and at the time of caching the routes hasn't been generated a type of conflict, however, in laravel 7 this has generated a mistake in the routes that are specified as:Route::get('/', '.....')
A solution implemented in a project to solve this problem with the route cache was:
- Create a middleware with the following validation:
class RouteCache
{
public function handle(Request $request, Closure $next)
{
if ($request->path() === '/') {
$newURI = $request->server->get('REQUEST_URI') . 'index.php';
$request->server->set('REQUEST_URI', $newURI);
}
return $next($request);
}
}
- Add the middleware to the Kernel file in the middleware array:
protected $middleware = [
....,
\App\Http\Middleware\RouteCache::class,
];
With this, what is achieved is that if a route /
is declared within the project, the middleware validates when trying to access it and overwrites the REQUEST_URI
value that the request carries by adding index.php
(this will continue being transparent to the end user)
Reference
이 문제에 관하여(Laravel 7: 캐시 경로 오류), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://dev.to/davidv99/laravel-7-cache-route-error-m8g텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)