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

You are not logged in.

Announcement

#1 2020-12-15 13:49:09

snadeau
New member
From: Montreal, Canada
Registered: 2020-12-07
Posts: 6

"Access-Control-Allow-Origin header contains multiple values"

Hi,

I have read your docs about the CORS policy for Apache and Nginx. I have added the required code, but I get the following error message when I look at the browser console:

[== Undefined ==]
Access to XMLHttpRequest at 'https://livehelper.caifan.casa/index.php/en/widgetrestapi/settings?vid=04106230abe9a53e237c&tz=America%2FToronto&r=%252F%252Fcaifan.casa%252Fmontreal%252Fmenus&l=%252F%252Fcaifan.casa%252F&dt=Online%2520Order!%2520-%2520Caifan&dep=1&theme=1' from origin 'https://caifan.casa' has been blocked by CORS policy: The 'Access-Control-Allow-Origin' header contains multiple values '*, https://caifan.casa', but only one is allowed.

helperFunctions.js:163

GET https://livehelper.caifan.casa/index.php/en/widgetrestapi/settings?vid=04106230abe9a53e237c&tz=America%2FToronto&r=%252F%252Fcaifan.casa%252Fmontreal%252Fmenus&l=%252F%252Fcaifan.casa%252F&dt=Online%2520Order!%2520-%2520Caifan&dep=1&theme=1 net::ERR_FAILED

value *** helperFunctions.js:163
r *** index.js:259
(anonymous) *** index.js:837
(anonymous) *** index.js:847
LiveHelperChat *** index.js:1
s *** bootstrap:63
LiveHelperChat *** bootstrap:200
(anonymous) *** index.js?20201115:1

So I have ran a grep command in order to find where the header is multiplied. Here are the locations where that header is set:

[== Undefined ==]
/var/www/vhosts/caifan.casa/livehelper.caifan.casa/lib/core/lhrestapi/lhrestapivalidator.php:        header('Access-Control-Allow-Origin: *');
/var/www/vhosts/caifan.casa/livehelper.caifan.casa/lib/core/lhcore/UploadHandler.php:        $this->header('Access-Control-Allow-Origin: '.$this->options['access_control_allow_origin']);
/var/www/vhosts/caifan.casa/livehelper.caifan.casa/doc/http_conf_examples/.htaccess.example:  Header always Set Access-Control-Allow-Origin "*"
/var/www/vhosts/caifan.casa/livehelper.caifan.casa/modules/lhchat/logevent.php:header('Access-Control-Allow-Origin: *');
/var/www/vhosts/caifan.casa/livehelper.caifan.casa/modules/lhchat/extendcookie.php:header('Access-Control-Allow-Origin: *');
/var/www/vhosts/caifan.casa/livehelper.caifan.casa/modules/lhchat/updatejsvars.php:header ( 'Access-Control-Allow-Origin: *' );
/var/www/vhosts/caifan.casa/livehelper.caifan.casa/modules/lhchat/setnewvid.php:header ( 'Access-Control-Allow-Origin: *' );
/var/www/vhosts/caifan.casa/livehelper.caifan.casa/modules/lhchat/updateattribute.php:header ( 'Access-Control-Allow-Origin: *' );
/var/www/vhosts/caifan.casa/livehelper.caifan.casa/modules/lhchat/refreshcustomfields.php:header('Access-Control-Allow-Origin: *');
/var/www/vhosts/caifan.casa/livehelper.caifan.casa/modules/lhfile/storescreenshot.php:header('Access-Control-Allow-Origin: *');
/var/www/vhosts/caifan.casa/livehelper.caifan.casa/modules/lhrestapi/startchat.php:header('Access-Control-Allow-Origin: *');
/var/www/vhosts/caifan.casa/livehelper.caifan.casa/modules/lhrestapi/logout.php:header('Access-Control-Allow-Origin: *');
/var/www/vhosts/caifan.casa/livehelper.caifan.casa/modules/lhrestapi/swagger.php:header('Access-Control-Allow-Origin: *');
/var/www/vhosts/caifan.casa/livehelper.caifan.casa/modules/lhrestapi/setoperatorstatus.php:header('Access-Control-Allow-Origin: *');
/var/www/vhosts/caifan.casa/livehelper.caifan.casa/modules/lhrestapi/departaments.php:header('Access-Control-Allow-Origin: *');
/var/www/vhosts/caifan.casa/livehelper.caifan.casa/modules/lhrestapi/setinvisibilitystatus.php:header('Access-Control-Allow-Origin: *');
/var/www/vhosts/caifan.casa/livehelper.caifan.casa/modules/lhrestapi/login.php:header('Access-Control-Allow-Origin: *');
/var/www/vhosts/caifan.casa/livehelper.caifan.casa/modules/lhrestapi/setnewvid.php:header('Access-Control-Allow-Origin: *');
/var/www/vhosts/caifan.casa/livehelper.caifan.casa/modules/lhcobrowse/storenodemap.php:header('Access-Control-Allow-Origin: *');
/var/www/vhosts/caifan.casa/livehelper.caifan.casa/modules/lhcobrowse/finishsession.php:header('Access-Control-Allow-Origin: *');

So, from there, I don't know what to do... Could it be possible that header in those php files is causing issues?

Thanks in advance

Offline

#2 2020-12-15 13:51:32

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

Re: "Access-Control-Allow-Origin header contains multiple values"

Hi,

You did not told what you are using nginx or apache.. If nginx you can try to remove rules under " location / {" section.

Offline

#3 2020-12-15 14:03:40

snadeau
New member
From: Montreal, Canada
Registered: 2020-12-07
Posts: 6

Re: "Access-Control-Allow-Origin header contains multiple values"

Apache with nginx as proxy. Should I try as you suggested for nginx?

Offline

#4 2020-12-15 14:06:15

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

Re: "Access-Control-Allow-Origin header contains multiple values"

But where does the main configuration comes from nginx or apache. As for nginx there headers set for php files under  " location / {" so just try to remove them. Headers in php is fine as long server itself does not send them again for php request...

Offline

Board footer