November 22, 2022
GET response content type settings in CF2021
November 22, 2022
GET response content type settings in CF2021
Newbie 1 posts
Followers: 0 people

Seeking help for the following issue:

Our shop is running two Adobe ColdFusion servers, a development and a production. Production is on ColdFusion 2018 and development is on ColdFusion 2021. When upgrading the development server to 2021, we chose to migrate the server administrator panel settings manually and most likely missed several. We now have the following problem:

In one of our web apps, a GET request (from superagent) is being made to a REST API URL to pull in some JSON. On production, the request comes back with ‘content-type’ of ‘application/JSON’, but on the development server, it comes back with ‘content-type’ of ‘text/plain’. This is causing the contents of the request to break code downstream because the field names are different (‘response.text’ rather than ‘response.body’). Relevant snippet:

export const makeGetRequest = (url, callback) => {
    window.pendingRequests ? ++window.pendingRequests : window.pendingRequests = 1;
        .set('Content-Type', 'application/json')
        .end((err, response) => {
            const data = response.body;
            if (data === null) {
            if (err) callback(err);
             else if (data && data.Message) callback(new Error(data.Message));
             else callback(null, data);

Note that manually setting the content type to application/JSON with .set is not resolving the issue. Neither does accessing response.text instead of response.body; the text contents are formatted differently.

The scripts are identical on development and production, so we are left to conclude that the problem must be a server setting to do with JSON serialization, response header content type headings, or something in that domain. Does anyone know what the setting in question is? The ColdFusion server admin panel is so big and we’ve spent a good deal of time crawling through it changing settings to match production, with no success so far.

  1. Tried manually setting the content type of the response header to application/JSON. Contents do not parse correctly in downstream code.
  2. Tried accessing the response.text field instead of the null response.body field. Contents do not parse correctly in downstream code.
  3. Have been searching for a ColdFusion admin panel setting that can account for the difference between our installations, but have not yet identified a setting that can resolve the issue.

StackOverflow link:

Add Comment