Jesse Kuzy
Jesse Kuzy

Reputation: 11

What ColdFusion server settings can affect superagent 'get' content types?

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;
    request
        .get(url)
        .set('Content-Type', 'application/json')
        .end((err, response) => {
            --window.pendingRequests;
            const data = response.body;
            if (data === null) {
                console.log(url);
            }
            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.

Upvotes: 1

Views: 89

Answers (1)

Adrian J. Moreno
Adrian J. Moreno

Reputation: 14859

Can you test the GET request to the CF API endpoint with an independent program like Postman? If so, does the request show different content types?

Can you export the CF admin settings from the production server as a CAR file, then import that into the development server? Likely there's a setting difference between the two servers. Alternatively, you could compare the neo*.xml files between the two to see if any specific settings jump out as the culprit. You can't copy the files between versions of ACF, but you should be able to see the relative setting values.

Upvotes: 2

Related Questions