aws / amazon-q-connectjs

https://aws.amazon.com/connect/q/
Apache License 2.0
6 stars 3 forks source link

Amazon Q Connect unable to make API calls when embedded #39

Open pf-dwong opened 3 days ago

pf-dwong commented 3 days ago

When Amazon Q Connect is embedded within an iframe the library is unable to make API calls due to a bug in communicationProxy.ts in the subscribeToChannel function.

This line of code tries to check if the event's source.location is not equal to either the window.parent.location or the window.top.location.

if ((e.source as Window)?.location !== ((window.top || window.parent).location)) return;

If it isn't then it exits the function and does not continue to make the API call. The issue is that window.top will never be null so the expression (window.top || window.parent).location will always evaluate to window.top.location. When Amazon Q Connect is embedded e.source.location will never equal window.top.location so the function will always exit early.

A proposed solution would be to individually check e.source.location against both window.top.location and window.parent.location

TheCloudlessSky commented 1 day ago

When Amazon Q Connect is embedded

To add to this, when the app calling the amazon-q-connectjs library is embedded as an iframe App inside of Amazon Connect, it fails to communicate with the API because of these conditions. If the app is opened standalone (not in an iframe), this works without issue.