aws / aws/amazon-q-connectjs

Amazon Q Connect unable to make API calls when embedded

Open
#39 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
14
Forks
11
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

Open the contributing guide

Research direction

Start in communicationProxy.ts at the subscribeToChannel function and inspect how the event source is compared with window.top and window.parent. Reproduce the embedded Amazon Q Connect case, then verify that API calls continue for the valid parent source while unrelated event sources are still rejected.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, frontend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.