'No 'Access-Control-Allow-Origin' header is present' error when loading external JS in UI Page pop up

Ian-Fusion3
Tera Guru

I have an external JS library that I am loading into a UI Page to handle some file manipulation. When I select "Try It" from the UI Page's record it loads the external JS correctly. However the moment I try to load the UI Page from a UI Action with GlideModal I receive the following error message.

Access to XMLHttpRequest at 'https://EXTERNAL_FILE_URL' from origin 'https://CLIENTURL.service-now.com' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

5 REPLIES 5

Community Alums
Not applicable

As it sees it as extenral resource (especially if using CDN) you either should set CORS rules or just add it as a client script (the entire library) and call its with 

<script src="<scope>.<name of this lib as you named it>.jsdbx" />
If again error - add it tot he macro/ui page of the modal itself also. 
 
Hope that helkps somehow.
Cheers,
Joro

Which REST API would I choose in the CORS Rule? I tried a few different variations but it didn't appear to make any difference.

Community Alums
Not applicable

Hi Ian, 

it depends, but try with Glide UI and Glide table. I'd use the first approach to add the entire contents of the external lib into a UI Script, but I dont know all the details and stuff of your task, so thats just an assumption 🙂

Try and let me know if it allowed you to load the lib

 

Cheers,

Joro

Hmmm neither Glide UI or Glide table worked. I won't be able to load the lib into UI scripts there far too many files in this library to make loading it in that way work. It's just seems silly that it works when I go the the UI page directly, but doesn't work when I pop it up over a form with GlideModal.