Live Helper Chat support forum.. Forum is locked. New place for questions - Github Discussions

You are not logged in.

Announcement

#1 2021-04-29 08:39:56

srichards
Member
Registered: 2014-11-26
Posts: 15

LHRESTAPI and CORS

Pulling my hair out with this one....

Access to XMLHttpRequest at 'https://mydomain/widgetrestapi/settings?vid=a13e1fa47b107e31c0de&hnh<LONG STRING>&theme=1' from origin 'https://mydomain' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
helperFunctions.js:164

GET https://mydomain/widgetrestapi/settings?vid=a13e1fa47b107e31c0de&hnh<LONG STRING>&theme=1 net::ERR_FAILED

I've tried adding into helperfunctions.js but not sure if ive missed something obvious...

                   

[== JavaScript ==]
LINE 155+        request.setRequestHeader("Access-Control-Allow-Origin", "*");

1619686262_capture.png

Anyone ideas?

Last edited by srichards (2021-04-29 09:11:35)

Offline

#2 2021-04-29 09:17:58

remdex
Administrator
From: Lithuania
Registered: 2012-09-23
Posts: 3,661
Website

Re: LHRESTAPI and CORS

Offline

#3 2021-04-29 10:26:30

srichards
Member
Registered: 2014-11-26
Posts: 15

Re: LHRESTAPI and CORS

Hi remdex,

Thanks for this. I have added this in but i think the issue is REACT.
The widget works fine on non-react sites but the REACT site has the issue.

Is there any other way to use the snippet in REACT maybe NPM or something ?

Thanks

Offline

#4 2021-04-29 10:37:55

remdex
Administrator
From: Lithuania
Registered: 2012-09-23
Posts: 3,661
Website

Re: LHRESTAPI and CORS

No this error is exactly related to CORS part. This .htaccess file has to be added .htaccess where index.php of lhc is located.

Offline

#5 2021-04-29 10:54:47

srichards
Member
Registered: 2014-11-26
Posts: 15

Re: LHRESTAPI and CORS

i have added .htaccess with the recommendations and the other websites with the widget work fine just not the REACT site.

I will keep trying....

Offline

#6 2021-04-29 11:21:34

remdex
Administrator
From: Lithuania
Registered: 2012-09-23
Posts: 3,661
Website

Re: LHRESTAPI and CORS

react has nothing to do. Just google about CORS and what it means...

Offline

Board footer