Refused to set unsafe header “Connection” when adding a product to cart in Virtuemart in Joomla! 1.5

R

How Can We Help?

Refused to set unsafe header “Connection” when adding a product to cart in Virtuemart in Joomla! 1.5

Complete Error:

Refused to set unsafe header “Connection”
XMLHttpRequest cannot load http://www.yourdomain.com/index.php. Origin http://yourdomain.com is not allowed by Access-Control-Allow-Origin.

This seems to happen whenever you access your domain via the domain url without the www record. So the Ajax calls that are made when adding a product to the cart seem to make calls to the www.yourdomain.com url and sees it as a different website.

A simple workaround is to place the following in your .htaccess file

RewriteEngine on
 
RewriteCond %{http_host} ^yourdomain.com$ [nc]
 
RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [r=301,nc]

Also remember to replace yourdomain.com with your website domain name

About the author

Ian Carnaghan

I am a software developer and online educator who likes to keep up with all the latest in technology. I also manage cloud infrastructure, continuous monitoring, DevOps processes, security, and continuous integration and deployment.

About Author

Ian Carnaghan

I am a software developer and online educator who likes to keep up with all the latest in technology. I also manage cloud infrastructure, continuous monitoring, DevOps processes, security, and continuous integration and deployment.

Follow Me