Never worked with NGINX config before. I learned of this by Googling to see if needed to be configured for CORS and read up that it does. I was curious myself.
From what read, this will open up to all domain if it added into the config
add_header Access-Control-Allow-Origin *;
Try that first and restart NGINX then test it. If that fixes it then replace it with a config that is specific to your domains only. One line per domain.
I have tried both solutions above and nothing is working. Does not matter if I turn CORS off/ON change everything and still getting the console error:
Access to XMLHttpRequest at 'https://mymauitc.com/mtc/event' from origin 'https://mywordpress.com' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: The 'Access-Control-Allow-Origin' header contains multiple values 'https://mywordpress.com,(http://mywordpress.com).com', but only one is allowed.
It says only one is allowed, but before I was supporting multiple sites and using @joeyk Multidomain plugin as well.
Weird thing is the forms are showing, but on submit it just hangs
Console error:
Uncaught DOMException: Blocked a frame with origin "https://mymautic.com" from accessing a cross-origin frame.
at HTMLDocument.<anonymous> (https://mymautic.com/media/js/app.js?v178a5420:274:162)
at mightThrow (https://mymautic.com/media/js/libraries.js?v178a5420:355:18)
at process (https://mymautic.com/media/js/libraries.js?v178a5420:357:89)
Then I went and created a new form and everything worked on Preview.
I took the form and added it both using wp mautic short code and it did not work.
I added the javascript and on submit I get to the internal error page :“Uh oh! I think I broke it. If I do it again, please report me to the system administrator!”
If you are getting error 500, I would check the ngnix error log. It may tell you something in there.
That error log would be part of the ngnix log on the server which is not part of Mautic. You would probably would need to ask your server administrator to give you the copy of the error log if you don’t have root access.
Firstly thank you for everyone that tried to she some light on the matter and help out here.
We found the problem and I have to say it was my fault.
A long time ago we installed the MakeWebBetter plugin and this plugin on Wordpress went and created a ton of new custom fields which inevitably caused issues with creating new fields.
When I wanted to add new fields I would have to go and delete one of the custom fields and my issue was I went and did this inside the database by dropping a column using the command
alter tables leads drop column mob_whatever
This in turn started causing the error, and I must have done this about two weeks ago, and what happened was when Mautic went and wanted to create a new lead it would not find the correct column and was throwing a CRITICAL error that I simply ignored:
Column not found: 1054 Unknown column 'mwb_newsletter_subs' in 'field lis
SO what I did was go into custom fields and delete these fields, and everything was working again.
No idea what the CORS error was and why it was throwing that, but this is what fixed up the problem.
It was a very uncomfortable day but I learnt a good lesson - Keep Calm and Read The Logs! Try and understand and isolate the issue.