Skip to content

Commit

Permalink
Discovery API not loading on SSR apps in Safari and Incognito (#1404)
Browse files Browse the repository at this point in the history
* Update authn.js

Looks like page loaded before event listeners are added in Safari. Seems to be an issue with SSRs.

Addresses: onflow/fcl-discovery#106

* Add changeset

Co-authored-by: Chase Fleming <1666730+chasefleming@users.noreply.github.com>
  • Loading branch information
chasefleming and chasefleming authored Sep 7, 2022
1 parent 945ecd4 commit f9f1dab
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/young-mice-bow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@onflow/fcl": patch
---

Fixes issue where Discovery API was not loading for server side rendered applications on Safari or Chrome Incognito.
6 changes: 5 additions & 1 deletion packages/fcl/src/discovery/services/authn.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,12 @@ const HANDLERS = {
'"fcl.discovery" is only available in the browser.'
)
// If you call this before the window is loaded extensions will not be set yet
window.onload = async () => {
if (document.readyState === 'complete') {
fetchServicesFromDiscovery()
} else {
window.onload = async () => {
fetchServicesFromDiscovery()
}
}
},
[SERVICE_ACTOR_KEYS.UPDATE_RESULTS]: (ctx, _letter, data) => {
Expand Down

0 comments on commit f9f1dab

Please sign in to comment.