Script Tags Transformed to Fetch Calls

Lightning Web Security (LWS) transforms <script> tags into fetch calls. LWS downloads the script to evaluate it in the sandbox.

To enable the fetch calls to succeed:

  • Configure the connected-src CSP directive on the Salesforce site where the component runs to allow access to the script resource server. See Manage Trusted URLs.

  • Configure the resource server with cross-origin resource sharing (CORS) to add the origin of the Salesforce site to its allowed origins list. The component can then access server resources.