function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ashok Kumar 577Ashok Kumar 577 

Doing web chat CORS error comming

SwethaSwetha (Salesforce Developers) 
HI Ashok
Can you share more details of your issue like what is the action you are performing, debug logs/ console logs, endpoint, iif you are using any external javascript in your code?

In genral to fix CORS error you need to add the URLs of the web pages where you intend to add the chat window to the CORS whitelist.

Steps to add provided here: https://help.salesforce.com/articleView?id=extend_code_cors.htm&type=5#extend_code_cors
 
Hope this helps you. Please mark this answer as best so that others facing the same issue will find this information useful. Thank you
Ashok Kumar 577Ashok Kumar 577
// After Embedded service deployment I found Embedded Service Code Snippets



<style type='text/css'>
    .embeddedServiceHelpButton .helpButton .uiButton {
        background-color: #005290;
        font-family: "Arial", sans-serif;
    }
    .embeddedServiceHelpButton .helpButton .uiButton:focus {
        outline: 1px solid #005290;
    }
</style>

<script type='text/javascript' src='https://service.force.com/embeddedservice/5.0/esw.min.js'></script>
<script type='text/javascript'>
    var initESW = function(gslbBaseURL) {
        embedded_svc.settings.displayHelpButton = true; //Or false
        embedded_svc.settings.language = ''; //For example, enter 'en' or 'en-US'

        //embedded_svc.settings.defaultMinimizedText = '...'; //(Defaults to Chat with an Expert)
        //embedded_svc.settings.disabledMinimizedText = '...'; //(Defaults to Agent Offline)

        //embedded_svc.settings.loadingText = ''; //(Defaults to Loading)
        //embedded_svc.settings.storageDomain = 'yourdomain.com'; //(Sets the domain for your deployment so that visitors can navigate subdomains during a chat session)

        // Settings for Chat
        //embedded_svc.settings.directToButtonRouting = function(prechatFormData) {
            // Dynamically changes the button ID based on what the visitor enters in the pre-chat form.
            // Returns a valid button ID.
        //};
        //embedded_svc.settings.prepopulatedPrechatFields = {}; //Sets the auto-population of pre-chat form fields
        //embedded_svc.settings.fallbackRouting = []; //An array of button IDs, user IDs, or userId_buttonId
        //embedded_svc.settings.offlineSupportMinimizedText = '...'; //(Defaults to Contact Us)

        embedded_svc.settings.enabledFeatures = ['LiveAgent'];
        embedded_svc.settings.entryFeature = 'LiveAgent';

        embedded_svc.init(
            'https://spaansupport1-dev-ed.my.salesforce.com',
            'https://spaan-2-developer-edition.ap16.force.com',
            gslbBaseURL,
            '00D2w000002BUBz',
            'Amazon_service',
            {
                baseLiveAgentContentURL: 'https://c.la2-c2-ukb.salesforceliveagent.com/content',
                deploymentId: '5722w0000004iAP',
                buttonId: '5732w0000004kWC',
                baseLiveAgentURL: 'https://d.la2-c2-ukb.salesforceliveagent.com/chat',
                eswLiveAgentDevName: 'EmbeddedServiceLiveAgent_Parent04I2w000000PLCMEA4_1720383c57d',
                isOfflineSupportEnabled: false
            }
        );
    };

    if (!window.embedded_svc) {
        var s = document.createElement('script');
        s.setAttribute('src', 'https://spaansupport1-dev-ed.my.salesforce.com/embeddedservice/5.0/esw.min.js');
        s.onload = function() {
            initESW(null);
        };
        document.body.appendChild(s);
    } else {
        initESW('https://service.force.com');
    }
</script>  
SwethaSwetha (Salesforce Developers) 
HI Ashok, I have checked the code shared. Can you confirm if you were able to add the domain to CORS whitelist? Make sure to include the HTTPS protocol (unless you’re using your localhost).
Related: https://success.salesforce.com/answers?id=9063A000000e6veQAA
Thanks
Ashok Kumar 577Ashok Kumar 577
Thanks for support Using your first CORS whitelist guideline I resolved our problem.