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:
$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.
@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.
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.