Some users experiencing blank results and console errors related to CORS

We are getting reports of some users seeing blank results pages (Yext header and tabs showing but no results) on our integrated results page. In console they see CORS errors related to some files in Yext along with other errors. Has anyone experienced this issue?

Users on OS Windows 10 and seeing it on all browsers
Chrome- Version 86.0.4240.111 (Official Build) (64-bit)
Microsoft Edge 44.18362.449.0
Firefox- 82.0.2 (64-bit)

Pasting errors below
Access to fetch at ‘https://liveapi-cached.yext.com/v2/accounts/me/answers/autocomplete?v=20190101&api_key=94ff356b5ea079ab9499d4be2719171c&jsLibVersion=v1.6.2&sessionTrackingEnabled=true&input=COVID%20response&experienceKey=virtusa_answers&version=PRODUCTION&locale=en’ from origin ‘https://answers-virtusa.pagescdn.com’ has been blocked by CORS policy: The value of the ‘Access-Control-Allow-Origin’ header in the response must not be the wildcard ‘*’ when the request’s credentials mode is ‘include’.
answers.min.js:1 GET https://liveapi-cached.yext.com/v2/accounts/me/answers/autocomplete?v=20190101&api_key=94ff356b5ea079ab9499d4be2719171c&jsLibVersion=v1.6.2&sessionTrackingEnabled=true&input=COVID%20response&experienceKey=virtusa_answers&version=PRODUCTION&locale=en net::ERR_FAILED
t._fetch @ answers.min.js:1
t.request @ answers.min.js:1
t.get @ answers.min.js:1
t.get @ answers.min.js:1
t.queryUniversal @ answers.min.js:1
t.autoCompleteUniversal @ answers.min.js:1
r.fetchQueryIntents @ answers.min.js:1
r.debouncedSearch @ answers.min.js:1
(anonymous) @ answers.min.js:1
t.emit @ answers.min.js:1
r.set @ answers.min.js:1
t.set @ answers.min.js:1
t.setQuery @ answers.min.js:1
r.onCreate @ answers.min.js:1
t.init @ answers.min.js:1
t.create @ answers.min.js:1
t.addComponent @ answers.min.js:1
onReady @ ?query=COVID+response&referrerPageUrl=https%3A%2F%2Fwww.virtusa.com%2F:1
(anonymous) @ answers.min.js:1
Promise.finally (async)
t.init @ answers.min.js:1
initAnswers @ ?query=COVID+response&referrerPageUrl=https%3A%2F%2Fwww.virtusa.com%2F:1
onload @ ?query=COVID+response&referrerPageUrl=https%3A%2F%2Fwww.virtusa.com%2F:1
answers.min.js:1 Uncaught (in promise) Error: Universal search request failed
at https://assets.sitescdn.net/answers/v1.6/answers.min.js:1:221671
Caused By: TypeError: Failed to fetch
t @ answers.min.js:1
t @ answers.min.js:1
t @ answers.min.js:1
t @ answers.min.js:1
(anonymous) @ answers.min.js:1
Promise.then (async)
r.debouncedSearch @ answers.min.js:1
(anonymous) @ answers.min.js:1
t.emit @ answers.min.js:1
r.set @ answers.min.js:1
t.set @ answers.min.js:1
t.setQuery @ answers.min.js:1
r.onCreate @ answers.min.js:1
t.init @ answers.min.js:1
t.create @ answers.min.js:1
t.addComponent @ answers.min.js:1
onReady @ ?query=COVID+response&referrerPageUrl=https%3A%2F%2Fwww.virtusa.com%2F:1
(anonymous) @ answers.min.js:1
Promise.finally (async)
t.init @ answers.min.js:1
initAnswers @ ?query=COVID+response&referrerPageUrl=https%3A%2F%2Fwww.virtusa.com%2F:1
onload @ ?query=COVID+response&referrerPageUrl=https%3A%2F%2Fwww.virtusa.com%2F:1
VM63:1 Uncaught SyntaxError: Unexpected token q in JSON at position 0
at JSON.parse ()
at onMessage (iframe.js:1)
at z (iframe.js:1)
at p (iframe.js:1)
at iframe.js:1
at A (iframe.js:1)
onMessage @ iframe.js:1
z @ iframe.js:1
p @ iframe.js:1
(anonymous) @ iframe.js:1
A @ iframe.js:1

To clarify, the URL that they are accessing is Virtusa Answers | Locations, Services, FAQs, Solutions | Virtusa

Yes correct, for example Virtusa Answers | Locations, Services, FAQs, Solutions | Virtusa?

Seems most of the issues have now resolved themsleves, but some users still seeing this error

search?query=banking:1 Uncaught SyntaxError: Unexpected token q in JSON at position 0
at JSON.parse ()
at onMessage (iframe.js:1)
at z (iframe.js:1)
at p (iframe.js:1)
at iframe.js:1
at A (iframe.js:1)

Hello!

Glad to hear that the issues have resolved themselves. Fortunately, this JSON issue has an easy fix. We made a change in the Theme template that didn’t seem to make it into the repository’s overrided html.hbs. We want to change the iFrame message to a JSON string. In your /layouts/html.hbs, there is currently (line 92):

      window.iFrameResizer = {
        onReady: function() {
          window.parentIFrame.sendMessage(iframeGetSearchParams());
        },
      };

Could we try changing that to

      window.iFrameResizer = {
        onReady: function() {
          window.parentIFrame.sendMessage(JSON.stringify({
            params: iframeGetSearchParams(),
            replaceHistory: true
          }));
        },
      };

Hopefully that will remove the errors
Christian

1 Like

Hi Christian,

Thank you for the fix! Andrai, I’ve pushed this fix live and users should not be experiencing this error anymore.

To resolve, we’ve stopped overriding the html.hbs core file, and added our modification (jQuery import) to the headincludes.hbs file so that we get the new updates as the theme is upgraded.

Best,
Amani

Thanks @afarooque @christian confirmed the issue is resolved now.