Uncaught DOMException: Blocked a frame with origin "instanceA.service-now.com" from accessing a cross-origin frame
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2022 07:13 AM
Dear Experts!
I have a client script on instanceA that opens instanceB's login page in a pop-up window. I want to wait for the user to log in, once done, close the pop-up and reload/redirect the original/parent page to somewhere.
The pop-up shows instanceB and I can log in just fine, but the rest of my script is not proceeding because of the error. This means I can not automatically close the pop-up and refresh the page.
Error: Uncaught DOMException: Blocked a frame with origin "instanceA.service-now.com" from accessing a cross-origin frame.
ps.: If the pop-up points the user to the same instance, everything works like a charm
(...)
var params = 'scrollbars=no,resizable=no,status=no,location=no,toolbar=no,menubar=no,width=300,height=300,left=100,top=100';
var loginWin = window.open("https://instanceB.service-now.com/login", "instanceB", params);
(...)
As far as I understand, I'd probably need to create CORS rules on instanceB to allow instanceA to do it's thing - but I am failing to do so.
Can any of you point me in the right direction? CORS rule wants me to select a REST API... What would be that in my case?
EDIT: Copying over some information from one of my comments:
Some background info:
- We have 2 instances
- Some specific Agents mostly work in instanceA
- Occasionally they have to log into instanceB with their LOCAL accounts
- I want to speed up the process so that the login page of instanceB is shown as a pop-up within instanceA's browser tab
- While on the login page, they can use their password manager to automatically type in their credentials
- After the login was successfull, I want to close the pop-up and redirect the Agents to a calculated URL within instanceB in the parent window (where instanceA used to be)
After clicking the UI Action:
The script can not proceed with the closure of the pop-up and the redirection of the user because the error stops the execution.
I would like to emphasize that during development the pop-up pointed to the SAME instance and it was all fine. The issue only happened when I finalized my code and changed the pop-up to a different instance (a domain of a different origin)
Based on Google I came to the conclusion that I'd need CORS rules to enable Cross-Origin Resources to be run. I am not able to set these rules up in our ServiceNow instances because the documentation is not really telling me anything and I am unfamiliar with the topic.
Obviously if CORS rules are not the way to go just please also feel free to tell me..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2022 10:24 PM
Hi Gabor
unfortunately it is not really clear what your issue is.
You are asking for a solution, but you did not explain WHY you want to go the described way and what your goal is.
Kind regards
Maik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2022 02:42 AM
Hello Maik!
Thank you for the response.
Some background info:
- We have 2 instances
- Some specific Agents mostly work in instanceA
- Occasionally they have to log into instanceB with their LOCAL accounts
- I want to speed up the process so that the login page of instanceB is shown as a pop-up within instanceA's browser tab
- While on the login page, they can use their password manager to automatically type in their credentials
- After the login was successfull, I want to close the pop-up and redirect the Agents to a calculated URL within instanceB in the parent window (where instanceA used to be)
After clicking the UI Action:
The script can not proceed with the closure of the pop-up and the redirection of the user because the error stops the execution.
I would like to emphasize that during development the pop-up pointed to the SAME instance and it was all fine. The issue only happened when I finalized my code and changed the pop-up to a different instance (a domain of a different origin)
Based on Google I came to the conclusion that I'd need CORS rules to enable Cross-Origin Resources to be run. I am not able to set these rules up in our ServiceNow instances because the documentation is not really telling me anything and I am unfamiliar with the topic.
Obviously if CORS rules are not the way to go just please also feel free to tell me..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2022 03:04 AM
Hi
sounds to me like over-engineering and I am not sure if the effort justifies the little bit more benefit
Why don't you just open a new window with the URL in Instance B? ServiceNow will automatically offer the login page and after successful login ServiceNow will redirect to the target page automatically.
Kind regards
Maik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2022 03:11 AM
Hi!
We have single sign-on on our instances and in this case they need to use their LOCAL accounts. If I just open the instanceB in a new tab, SSO will sign them into the wrong account.