Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redirects no longer work in 3.9 #2344

Closed
bonesnap opened this issue Nov 17, 2017 · 3 comments
Closed

Redirects no longer work in 3.9 #2344

bonesnap opened this issue Nov 17, 2017 · 3 comments

Comments

@bonesnap
Copy link

Hello, I am able to successfully use this code in 3.8.1:

$app->get('/', function (Request $request, Response $response) {
	if (UserState::isLoggedIn()) {
		return $response->withHeader('Location', '/dashboard');
	}

	return $response->withHeader('Location', '/login');
})->setName('home');

However in 3.9 a white screen appears with no output (I do have displayErrorDetails set to true). There are no errors in my PHP error log and no errors in Apache, either.

The only way I can get a redirect to work is to replace the return lines above with: header("Location: /dashboard"); exit; but I much prefer to use the tools provided by the framework.

Thank you for reading!

Apologies if this has already been raised; I did not see it in the issue list.

@geggleto
Copy link
Member

Related to #2340

@akrabat
Copy link
Member

akrabat commented Nov 17, 2017

Change your code to return $response->withHeader('Location', '/login')->withStatus(302) or return $response->withRedirect('/login');

We'll improve this for 3.9.1.

@bonesnap
Copy link
Author

Thanks a lot! =]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants