Resolve X-Content-Type Mismatch for SCA 2018.2

To implement this patch, create a custom module to override the following files:

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: Create the Override File for checkout.environment.shortcache.ssp

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

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

    Find the following code:

                    response.setCDNCacheable(response.CACHE_DURATION_SHORT); 
    
                  

    Replace it with the following code:

                    response.setCDNCacheable(response.CACHE_DURATION_SHORT);
    response.setContentType('JAVASCRIPT'); 
    
                  

Step 3: Create the Override File for myaccount.environment.shortcache.ssp

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

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

    Find the following code:

                    response.setCDNCacheable(response.CACHE_DURATION_SHORT); 
    
                  

    Replace it with the following code:

                    response.setCDNCacheable(response.CACHE_DURATION_SHORT);
    response.setContentType('JAVASCRIPT'); 
    
                  

Step 4: Create the Override File for shopping.environment.shortcache.ssp

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

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

    Find the following code:

                    response.setCDNCacheable(response.CACHE_DURATION_SHORT); 
    
                  

    Replace it with the following code:

                    response.setCDNCacheable(response.CACHE_DURATION_SHORT);
    response.setContentType('JAVASCRIPT'); 
    
                  

Step 5: Prepare the Developer Tools for Your Patch – customFieldsMetadata.ssp

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 6: Prepare the Developer Tools for Your Patch – checkout.environment.shortcache.ssp

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/CheckoutApplicationExtension@1.0.0/ns.package.json

                    {
      "gulp": {
        "ssp-files": [
          "SuiteScript/*.ssp"
        ]
      },
      "overrides": {
        "suitecommerce/CheckoutApplication@X.Y.Z/SuiteScript/checkout.environment.shortcache.ssp" : "SuiteScript/checkout.environment.shortcache.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/CheckoutApplicationExtension": "1.0.0",
       ...
    } 
    
                  

Step 7: Prepare the Developer Tools for Your Patch – myaccount.environment.shortcache.ssp

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/MyAccountApplicationExtension@1.0.0/ns.package.json

                    {
      "gulp": {
        "ssp-files": [
          "SuiteScript/*.ssp"
        ]
      },
      "overrides": {
        "suitecommerce/MyAccountApplication@X.Y.Z/SuiteScript/myaccount.environment.shortcache.ssp" : "SuiteScript/myaccount.environment.shortcache.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/MyAccountApplicationExtension": "1.0.0",
       ...
    } 
    
                  

Step 8: Prepare the Developer Tools for Your Patch – shopping.environment.shortcache.ssp

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/ShoppingApplicationExtension@1.0.0/ns.package.json

                    {
      "gulp": {
        "ssp-files": [
          "SuiteScript/*.ssp"
        ]
      },
      "overrides": {
        "suitecommerce/ShoppingApplication@X.Y.Z/SuiteScript/shopping.environment.shortcache.ssp" : "SuiteScript/shopping.environment.shortcache.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/ShoppingApplicationExtension": "1.0.0",
       ...
    } 
    
                  

Step 9: Test and Deploy Your Patch

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

Step 10: 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