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
Ginjupalli AviGinjupalli Avi 

When i am adding 'https://www.google-analytics.com'to CORS, and trying to load my script file from lightning component.

When i am adding 'https://www.google-analytics.com'to CORS, and trying to load my script file from lightning component.Getting below error,
Error screen print
AbhishekAbhishek (Salesforce Developers) 
Please refer to the below link for reference.

The issue can be addressed using the built-in HTTP(S) Proxy. You can enable the proxy in the standard setup menu.

For Classic: Setup | Security Controls | Remote Site Settings
For Lightning: Setup | Security | Remote Site Settings

There you can add your own salesforce instance. e.g. eu1.salesforce.com (don't forget to enable https).
See more on how to Configure Remote Site Settings. 

In a second step, you have to modify your ajax request to set URL as "https://c.na1.visual.force.com/services/proxy"
The best solution is to use the fully documented HTTP Proxy service from Salesforce.


And for the above error, we also got official documentation (https://help.salesforce.com/articleView?id=000334858&type=1&mode=1).

For further reference, you can check this. (https://help.salesforce.com/articleView?id=extend_code_cors.htm&type=5)


I hope you find the above information is helpful. If it does, please mark as Best Answer to help others too.

Thanks.
 
Ginjupalli AviGinjupalli Avi
As per below link,
https://help.salesforce.com/articleView?id=extend_code_cors.htm&type=5
CORS does not support requests for unauthenticated resources, including OAuth endpoints. The one exception is the OpenID Connect discovery endpoint. You can access the OpenID Connect discovery endpoint when CORS is enabled. For all other OAuth endpoints, you must pass an OAuth token with requests that require it.

Google analytics link definetly need authentation so formally it won't support.To do the support on that is there any workaround is in place, if yes please suggest me for the next steps....
AbhishekAbhishek (Salesforce Developers) 
I haven't tried that scenario, You can reach salesforce support for further workarounds.