Resolve X-Content-Type Mismatch for SCA 2019.1

To implement this patch, create a custom module to override the customFieldsMetadata.ssp SuiteScript file, which is part of the CustomFields module.

If you are unfamiliar with implementing patches for SuiteCommerce Advanced (SCA), refer to:

Step 1: Create the Override File for customFieldsMetadata.ssp

  1. Following the instructions in the Patch Using Override Mode procedure, create a new directory and file: /Modules/extensions/CustomFieldsExtension@1.0.0/SuiteScript/customFieldsMetadata.ssp

  2. In the new customFieldsMetadata.ssp file, find and replace the following line of code with the provided code samples.

    Find the following code:

                    response.write('SC.ENVIRONMENT.customFieldsMetadata=' + JSON.stringify(metadata)); 
    
                  

    Replace it with the following code:

                    response.setContentType('JAVASCRIPT'); 
    response.write('SC.ENVIRONMENT.customFieldsMetadata=' + JSON.stringify(metadata)); 
    
                  

Step 2: Prepare the Developer Tools for Your Patch

When preparing the Developer Tools for your patch as described in the Patch Using Override Mode procedure, perform the following actions:

  1. Paste the following sample code into the new ns.package.json file that you created in the Modules directory: /Modules/extensions/CustomFieldsExtension@1.0.0/ns.package.json

                    {
      "gulp": {
        "ssp-files": [
          "SuiteScript/*.ssp"
        ]
      },
      "overrides": {
        "suitecommerce/CustomFields@X.Y.Z/SuiteScript/customFieldsMetadata.ssp" : "SuiteScript/customFieldsMetadata.ssp"
      }
    } 
    
                  
    Important:

    Replace the string, X.Y.Z, with the version of the module in your implementation of SCA.

  2. Open the distro.json file in the root SCA development directory and add your custom module to the modules object as described in the Patch Using Override Mode procedure. The following sample shows the value to add to the list of existing values that follow the “modules” key.

                    "modules": {
       "extensions/CustomFieldsExtension": "1.0.0",
       ...
    } 
    
                  

Step 3: Test and Deploy Your Patch

Follow the instructions provided in the Patch Using Override Mode procedure to test and deploy your patch.

Step 4: Check Custom SSPs

In addition to the customFieldsMetadata.ssp file, your custom SSPs may also be affected. Follow these instructions to confirm they are correctly set up.

  1. Review your custom SSPs to confirm that the Content-Type set in the response header matches the content returned.

  2. If no Content-Type is set, you will need to define the correct one for your custom SSP.

  3. Make sure the services you created to handle http requests follow best practices. See Create and Use SSP Applications

    If your services are not following best practice, you should extend ServiceController. See Create a Service to Handle HTTP Requests.

Related Topics

General Notices