private function getRedirectResponse(ServerRequestInterface $request, UriInterface $uri, ResponseInterface $response)
    {
        //Fix the basePath
        $generator = BasePath::getGenerator($request);

        if ($generator !== null) {
            $uri = $uri->withPath($generator($uri->getPath()));
        }

        return $response
            ->withStatus($this->redirectStatus)
            ->withHeader('Location', (string) $uri);
    }