This is the community forum. For a developer response use the Client Area.
Follow us on Facebook, Twitter and YouTube!

Multiple domains not working
#1

I installed commentics on mispicaderos.com, but I have also the same page (the same estructure, programing) in multiple domains: trovacamporella.com, cruisingmap.com, placeforlove.com

All of them are the same, bur different domain

The problem is that COMMENTICS only works in mispicaderos.com.
In all the rest domains, it is loaded, it shows post and form. (Even the BACKEND works!)
But if a user tries to post a message in those alternative domains, it does not do anything. No error and no working.

How to make it work for multidomains???

Thank you
Reply
#2

Commentics isn't a multidomain script. Where did you read that?

It needs an installation on each website.

Have you completed the interview?
Reply
#3

Hi, (sorry for delay on answering)

But the first version of Commentics worked prefectly on multidomain.
My website is just one, the only thing is the logo and some images change depending of the domain. So, there is just one place where I can installa commentics plugin..

In order to make it work, I have had to call it via iframe in the rest of domains. But it is not the best solution...

Regards,
Reply
#4

This will be because the earlier versions of Commentics didn't use ajax. With ajax, browsers by default implement a 'same-origin' policy meaning only ajax requests to the same domain work. To override this, you'll need to add a CORS directive to your site to allow cross-origin. In PHP you can do this using the header() function. It will need to be added at the beginning of your page, otherwise you'll get a 'headers already sent' error. Try to avoid allowing all domains using *. Instead just restrict it to the ones you want to allow. See below solution for this:

https://stackoverflow.com/a/7454204

Have you completed the interview?
Reply
#5

Ouch!!!
THANK YOU VERY MUCH!!!
I´ll try this
Reply
#6

uhmmm.
I know this is not commentics problem, but example code like this don´t work...
$allowedOrigins = [
"https://mispicaderos.com",
"https://trovacamporella.com"
];
if (in_array($_SERVER["HTTP_ORIGIN"], $allowedOrigins)) {
header("Access-Control-Allow-Origin: " . $_SERVER["HTTP_ORIGIN"]);
}

I get this message:

from origin 'https://trovacamporella.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Reply
#7

I think 'HTTP_ORIGIN' might be old. Try this:

PHP Code:
<?php 
$allowedOrigins
= [
"mispicaderos.com",
"trovacamporella.com"
];
if (
in_array($_SERVER["SERVER_NAME"], $allowedOrigins)) {
header("Access-Control-Allow-Origin: https://" . $_SERVER["SERVER_NAME"]);
}

Have you completed the interview?
Reply
#8

I tried it also, but same problem..
At mispicaderos.com work prefectly, but at trovacamporella does not... Sad
This is the error:

Access to XMLHttpRequest at 'https://mispicaderos.com/comentics_v34/comments/frontend/index.php?route=main/form/submit' from origin 'https://trovacamporella.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Any idea...?
Reply
#9

I´ve just tried to put this line
header("Access-Control-Allow-Origin: https://trovacamporella.com");

at the file of commentics index.php

Now, the CORS error has dissapeared, but the form stil don´t work.
A new JS error appeared:
at common-jq-jqui.min.js
This is where the error stops
r.fail(function(e, t, n) {
console && console.log && console.log(e.responseText)
})


(THANK YOU VERY MUCH BY THE WAY)
Reply
#10

Can you provide a link to the page where the form is? I'll then take a look.

Have you completed the interview?
Reply


Possibly Related Threads…
Thread / Author Replies Views Last Post
Last Post by Steven
06-Nov-2012, 03:09 PM

Forum Jump:


Users browsing this thread: 3 Guest(s)