# \[3.12.3\] Wrong status code returned with response

**URL:** <https://discourse.slimframework.com/t/3-12-3-wrong-status-code-returned-with-response/4294>\
**Category:** Questions\
**Created:** [July 17, 2020, 4:42am UTC](https://discourse.slimframework.com/t/3-12-3-wrong-status-code-returned-with-response/4294 "2020-07-17T04:42:28Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![treigh](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/treigh/32/1193_2.png) [@treigh](https://discourse.slimframework.com/u/treigh)\
**Post date:** [July 17, 2020, 4:42am UTC](https://discourse.slimframework.com/t/3-12-3-wrong-status-code-returned-with-response/4294/1 "2020-07-17T04:42:28Z")

</div>

Hi guys,

I’ve spent a few hours searching the forums, Stack Overflow and all the usual spots and I can almost guarantee that this issue is a rather strange one.

Everything worked normally until a few hours ago. No matter the resource requested, I’m always getting a `200` status code.

For example:

```auto
$app->get('/test-json', function (Request $request, Response $response, array $args = []) {
    $response = $response->withJson(['message' => 'error'], 400);    
    return $response;
});

// outputs {"message": "error} with status => 200

```

I’ve also disabled all middleware to be sure and even requested a nonexistent resource `test-json-b` to check. expecting a `404`, but the same happens here.

I’m running Slim `3.12.3` (upgraded from 3.0.0 a moment a go) on a macOS Catalina.

i’d appreciate a second pair of eyes.

---

<div class="post-metadata">

**Author:** ![tflight](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/tflight/32/1205_2.png) [@tflight](https://discourse.slimframework.com/u/tflight)\
**Post date:** [July 17, 2020, 4:05pm UTC](https://discourse.slimframework.com/t/3-12-3-wrong-status-code-returned-with-response/4294/2 "2020-07-17T16:05:42Z")

</div>

That code works perfectly for me and I get a 400 response, so the error is seemingly elsewhere. Have you tried disabling all of your other routes?

If you require Slim 3.0.0 does it work properly again?

---

<div class="post-metadata">

**Author:** ![treigh](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/treigh/32/1193_2.png) [@treigh](https://discourse.slimframework.com/u/treigh)\
**Post date:** [July 17, 2020, 4:46pm UTC](https://discourse.slimframework.com/t/3-12-3-wrong-status-code-returned-with-response/4294/3 "2020-07-17T16:46:52Z")

</div>

@tflight thanks for checking in. I was actually running Slim 3.0.0 when the issue first started. i figured I’d try and upgrade it to see if anything changes, but no. Let me try disabling all other routes to check.

---

<div class="post-metadata">

**Author:** ![treigh](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/treigh/32/1193_2.png) [@treigh](https://discourse.slimframework.com/u/treigh)\
**Post date:** [July 17, 2020, 4:49pm UTC](https://discourse.slimframework.com/t/3-12-3-wrong-status-code-returned-with-response/4294/4 "2020-07-17T16:49:56Z")

</div>

Wow. I disabled all other routes and things are back to normal. i’ll isolate each route to spot the faulty one.

Thanks a lot! This saved me so much headache.

---

<div class="post-metadata">

**Author:** ![tflight](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/tflight/32/1205_2.png) [@tflight](https://discourse.slimframework.com/u/tflight)\
**Post date:** [July 17, 2020, 5:14pm UTC](https://discourse.slimframework.com/t/3-12-3-wrong-status-code-returned-with-response/4294/5 "2020-07-17T17:14:04Z")

</div>

Play with the order of routes as well as you might have multiple routes that could match, but the first match will win. 🙂

---

<div class="post-metadata">

**Author:** ![treigh](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/treigh/32/1193_2.png) [@treigh](https://discourse.slimframework.com/u/treigh)\
**Post date:** [July 17, 2020, 11:33pm UTC](https://discourse.slimframework.com/t/3-12-3-wrong-status-code-returned-with-response/4294/6 "2020-07-17T23:33:28Z")

</div>

Funny enough, things work well when I move the code above out of the faulty route into another. I’m sure some dependency is playing tricks on me, but that’s a fight for another day. I’m happy things are working.

Thanks again for the great help.
