Hello,
I built this Middleware class to redirect the requested page if a language it is not defined on the url
For instance:
If someone goes to /users/login the application would redirect the browser to /en_US/users/login
The class in questions is:
class LanguageParameterMiddleware
{
private $myDefaultLanguage = 'en_US';
public function __invoke($request, Response $response, $next) {
$response = $next($request, $response);
if (!$request->getParam('lang')) {
$response->withLocation('/' . $this->myDefaultLanguage .
$request->getRequestTarget()
);
}
return $response;
}
}
The response->withLocation is being executed, but no redirection is happenning. I do not see the Location header being sent back on the Firefox Developer Tools
Any idea what I am doing wrong?