# Slim-Http error

**URL:** <https://discourse.slimframework.com/t/slim-http-error/3145>\
**Category:** Questions\
**Created:** [May 4, 2019, 5:36pm UTC](https://discourse.slimframework.com/t/slim-http-error/3145 "2019-05-04T17:36:44Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![leodeville](https://avatars.discourse-cdn.com/v4/letter/l/ebca7d/32.png) [@leodeville](https://discourse.slimframework.com/u/leodeville)\
**Post date:** [May 4, 2019, 5:36pm UTC](https://discourse.slimframework.com/t/slim-http-error/3145/1 "2019-05-04T17:36:44Z")

</div>

In Slim 3, I could do:  
$app-\>group(’’’, function () use ($app) {  
$app-\>get(’/login’,‘LoginController:get’)-\>setName(‘login’);  
$app-\>post(’/login’,‘LoginController:post’);  
})-\>add(new Guest($container));

But now with Slim 4 I have migrated everything, especially Guest:  
$response = $handler-\>handle($request);

```
if (Sessions::isAuthenticated()) {
	return $response->withRedirect("URL");
}

return $response;

```

And I get an error message when I try to make a POST request.

Call to undefined method Slim\Psr7\Response::withRedirect()

But the middleware works perfectly with a GET request

---

<div class="post-metadata">

**Author:** ![l0gicgate](https://avatars.discourse-cdn.com/v4/letter/l/41988e/32.png) [@l0gicgate](https://discourse.slimframework.com/u/l0gicgate)\
**Post date:** [May 4, 2019, 5:54pm UTC](https://discourse.slimframework.com/t/slim-http-error/3145/2 "2019-05-04T17:54:32Z")

</div>

That’s because Slim-Psr7 does not implement that method anymore. You’ll need to use the Slim-Http decorators on top of Slim-Psr7.

Also, don’t use `$app` to add routes within a group. You need to use the `RouteCollectorProxy` like so:

```auto
$app->group(function (RouteCollectorProxy $group) {
    $group->get(...);
});

```

---

<div class="post-metadata">

**Author:** ![leodeville](https://avatars.discourse-cdn.com/v4/letter/l/ebca7d/32.png) [@leodeville](https://discourse.slimframework.com/u/leodeville)\
**Post date:** [May 4, 2019, 6:06pm UTC](https://discourse.slimframework.com/t/slim-http-error/3145/3 "2019-05-04T18:06:40Z")

</div>

The problem is that I already use Slim-Http, $request-\>withRedirect() works very well with a GET request but not with a POST request

---

<div class="post-metadata">

**Author:** ![l0gicgate](https://avatars.discourse-cdn.com/v4/letter/l/41988e/32.png) [@l0gicgate](https://discourse.slimframework.com/u/l0gicgate)\
**Post date:** [May 4, 2019, 11:53pm UTC](https://discourse.slimframework.com/t/slim-http-error/3145/4 "2019-05-04T23:53:09Z")

</div>

I need to see more code in order to be able to give you an answer. If you could gist something up with your index.php, GET/POST routes, etc.

---

<div class="post-metadata">

**Author:** ![leodeville](https://avatars.discourse-cdn.com/v4/letter/l/ebca7d/32.png) [@leodeville](https://discourse.slimframework.com/u/leodeville)\
**Post date:** [May 5, 2019, 4:02pm UTC](https://discourse.slimframework.com/t/slim-http-error/3145/5 "2019-05-05T16:02:42Z")

</div>

If I am logged in and go to /login it redirects and no errors.  
If I am disconnected and I go to /profile it redirects and no errors.

If I go to login and make a POST request, then I will get the error “Call to undefined method Slim\Psr7\Response::withRedirect()”

If I remove $group-\>post(’/login’,‘LoginController:post’); from the group, everything works perfectly but even players already connected can access this page with a POST request.

---

<div class="post-metadata">

**Author:** ![l0gicgate](https://avatars.discourse-cdn.com/v4/letter/l/41988e/32.png) [@l0gicgate](https://discourse.slimframework.com/u/l0gicgate)\
**Post date:** [May 5, 2019, 9:00pm UTC](https://discourse.slimframework.com/t/slim-http-error/3145/6 "2019-05-05T21:00:14Z")

</div>

See [https://github.com/KoboldMalade/SlimError/pull/1](https://github.com/KoboldMalade/SlimError/pull/1) for solution.
