Mautic Community Forums

CORS error: No 'Access-Control-Allow-Origin' header is present

Hi all.



I’m experimenting with mautic on a local server.

I’ve also got a WordPress site on the same server.

I’ve found the js snippet for implimenting tracking, and embedded it in the wp site.



When I load the wp site, the mautic resource is successfully requested.

However, the console returns a CORS error:

Code:
XMLHttpRequest cannot load http://mautic.dev/mtc/event. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://wp3.dev' is therefore not allowed access

I've gone back to the mautic dashboard, and gone to 'configuration' -> 'CORS Settings'.
At first I added the domain 'wp3.dev.' to the textfield 'Valid Domains'.

I then went back to the wp site and reloaded. I still got the error.
So I went back to mautic and togged 'Restrict Domains' off.
Then I went back to the wp site and reloaded.

Alas, the error is still thrown in the browser console.

What should my next step be?

Hi all.

I’m experimenting with mautic on a local server.
I’ve also got a WordPress site on the same server.
I’ve found the js snippet for implimenting tracking, and embedded it in the wp site.

When I load the wp site, the mautic resource is successfully requested.
However, the console returns a CORS error:

XMLHttpRequest cannot load http://mautic.dev/mtc/event. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://wp3.dev' is therefore not allowed access

I’ve gone back to the mautic dashboard, and gone to ‘configuration’ -> ‘CORS Settings’.
At first I added the domain ‘wp3.dev.’ to the textfield ‘Valid Domains’.

I then went back to the wp site and reloaded. I still got the error.
So I went back to mautic and togged ‘Restrict Domains’ off.
Then I went back to the wp site and reloaded.

Alas, the error is still thrown in the browser console.

What should my next step be?

Hello, have you solved this issue? If yes, how?

Tks.

I removed the trailing / from my domain name and it seems to work.

+1 also worked for me.