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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2020 11:58 AM
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2020 12:23 PM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2020 01:01 PM
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2020 01:21 PM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2020 05:03 PM
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.