DMXzone Mailer Support Product Page

Solved

Form stopped working - getting 'CORS' error messages

Reported 17 Dec 2019 10:42:01
1
has this problem
17 Dec 2019 10:42:01 Bruce Wilkie posted:
Hi there

The forms on one of my clients' website have stopped working and in the console tab of the Developer Tools window I'm seeing two 'CORS' related errors/warnings on submit.

"Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at fillworth.com/dmxConnect/api/BrochureRequestFormNew.php. (Reason: CORS header 'Access-Control-Allow-Origin' missing)."

"Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at fillworth.com/dmxConnect/api/BrochureRequestFormNew.php. (Reason: CORS request did not succeed)."

Any ideas what might be causing this? I've googled CORS and found this site: jonhilton.net/cross-origin-request-blocked/

But I don't really understand what they're saying there. Looks like there would be a potential problem if the resource (BrochureRequestFormNew.php) was in a subdomain or my website, but it isn't so don't see how the problem is being caused.

Are you able to look and see what the problem is? I thought it might be down to the htaccess file as that has redirects in it, but I deleted that, refreshed the browser cache and the problem still there.

Any help you can suggest much appreciated.

Thaks
Bruce

thanks
Bruce

Replies

Replied 17 Dec 2019 11:17:40
17 Dec 2019 11:17:40 Teodor Kuduschiev replied:
Hello Bruce,
Can you provide a link to your page, where i can check this?
Replied 17 Dec 2019 11:19:52
17 Dec 2019 11:19:52 Bruce Wilkie replied:
Hi Teodor

www.fillworth.com/

There's a 'Request Brochure' form half way down the right hand column.

thanks
Bruce
Replied 17 Dec 2019 11:22:23
17 Dec 2019 11:22:23 Teodor Kuduschiev replied:
Are you sure this is not related to you loading the site through "" and not "" and that's probably the problem on the server?
Replied 17 Dec 2019 11:25:16
17 Dec 2019 11:25:16 Bruce Wilkie replied:
Hi Teodor

I'm not understanding what you mean there?

"" and ""

Was there meant to be something inside the quotation marks?
Replied 17 Dec 2019 11:26:10
17 Dec 2019 11:26:10 Teodor Kuduschiev replied:
Yes, sorry.

Are you sure this is not related to you loading the site through:
http://

and not:
https://

and that's probably the problem on the server?
Replied 17 Dec 2019 11:36:03
17 Dec 2019 11:36:03 Bruce Wilkie replied:
I did wonder about that but it doesn't seem to matter.

The form fails with the CORS error whichever I try. And we're only able use http now that I've deleted the htaccess file as that was forcing https. My first thought was a problem with htaccess but deleting that and the forced https didn't help.

Also, the site is calling the 'remote resource' mentioned in the error messages (fillworth.com/dmxConnect/api/BrochureRequestFormNew.php) locally so that shouldn't be an issue should it?

<form action="dmxConnect/api/BrochureRequestFormNew.php" method="post" id="brochurerequest" is="dmx-serverconnect-form" dmx-on:success="brochurerequest.reset()" onsuccess="MM_popupMsg('Request sent. A copy of our brochure should arrive at the inbox for the email you specified shortly. Please contact us if you do not receive the brochure in timely fashion.');">

But I'm really not sure as I've never heard of this CORS issue before so I'm completely in the dark
Replied 17 Dec 2019 11:39:04
17 Dec 2019 11:39:04 Teodor Kuduschiev replied:
Not sure why and how did you decide it was a great idea to delete the .htaccess file.
The problem currently, with the non-https version is exactly related to an http site trying to load https resources.
Your base tag points to an https version
<base href = "https://fillworth.com" />


Please restore your original .htaccess file so i can check what's wrong on your site.
Replied 17 Dec 2019 11:43:03
17 Dec 2019 11:43:03 Bruce Wilkie replied:
Now restored.

Was just trying different things to see what effect if any it had on the errors/warnings to try to get a clue as to the problem.
Replied 17 Dec 2019 11:47:10
17 Dec 2019 11:47:10 Bruce Wilkie replied:

This is the content of the htaccess file in case useful

Replied 17 Dec 2019 12:20:31
17 Dec 2019 12:20:31 Teodor Kuduschiev replied:
What steps do you have in your server action?
Replied 17 Dec 2019 12:24:35
17 Dec 2019 12:24:35 Teodor Kuduschiev replied:
Actually it seems some of the 301 redirects on your site (probably from your .htaccess) which causes this error.
Try removing them one by one to see which one causes the problem.
Replied 17 Dec 2019 12:27:08
17 Dec 2019 12:27:08 Bruce Wilkie replied:
Screenshot of steps: prntscr.com/qc0sqn

Condition is a honey trap.

'Else' step is just setting a non-related variable as I get an error message if I don't put something in there.

The two send mail steps are one sending email with brochure to site visitor and one sending email notification to my client
Replied 17 Dec 2019 12:36:33
17 Dec 2019 12:36:33 Bruce Wilkie replied:
Hi Teodor

Fixed it. Thanks to you. It was to do with the htaccess file, but the solution was in the tag in the page:

<base href = "https://fillworth.com" />


Once I started commenting out lines in the htaccess file I noticed that one of them was forcing 'www.' as well as 'https' and that doesn't match with the <base> tag which doesn't include 'www.'

So I changed to
<base href = "https://www.fillworth.com" />
and that's fixed it.

Thanks so much for your patience and help with this. Now updating all the oher pages and that should be an end to it

regards
Bruce

Reply to this topic