Cloudflare overwriting Content-Type as text/html instead of application/json

API response from http://lab.ideafarm.co.za/hilos/webhook/msisdn_check (GET or POST for testing) is returning Content-Type text/html instead of application/json.

PHP code is explicitly returning json:

    $result = [
      "fname" => "John",
      "lname" => "Luke",
      "accid" => "accid000001"
    ];
    $payload = json_encode( $result);
    $response->getBody()->write( $payload );
    return $response
    ->withHeader('Content-Type', 'application/json;charset=UTF-8;')
    ->withStatus(201);

Testing in Postman with same codebase (Slimframework v4) on localhost and on another non-Cloudflare DNS domain on same server returns json.

I see other posts on the forum unanswered so I’m trying my luck here. Thank you.

Afraid, this is not a Cloudflare issue, but your server sends that mime type.

$ curl -ik https://lab.ideafarm.co.za/hilos/webhook/msisdn_check --connect-to [SERVER_ADDRESS] | grep content
content-type: text/html; charset=UTF-8

Also, your server certificate has expired and you need to renew that and fix your insecure encryption mode on Cloudflare. Right now your site has no proper encryption.

1 Like

Thank you Sandro, I appreciate the response. Yup I’m on the SSL issue.

No worries, just make sure you also fix the encryption mode on Cloudflare. That should be Full Strict.

I understand, but the response for that particular hostname here is relevant and this is where the server returns said mime type.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.