• Resolved T_Dev

    (@t_dev)


    Hello,

    Form submissions with “Contact Forms 7” are bring block by CORS,
    the site is running WPML and configured to serve 2 domains, one language per domain.

    When trying to submit a form from the original language (domain1.com), it works fine.
    When trying to submit a form from a different language (domain2.com), the calls are being blocked by CORS:

    “Access to XMLHttpRequest at ‘https://www.domain1.com/wp-json/contact-form-7/v1/contact-forms/3025/feedback’ (redirected from ‘https://www.domain2.com/wp-json/contact-form-7/v1/contact-forms/3025/feedback’) from origin ‘https://www.domain2.com’ has been blocked by CORS policy: Request header field x-requested-with is not allowed by Access-Control-Allow-Headers in preflight response.”

    The problem persists as long as W3TC is enabled.
    Turning off any or all the caching modules did not help, disabling the plugin is the only solution.

    Excluding a page is also not viable solution, since we are using the forms in multiple pages.

    Is there a way to configure the plugin to allow REST calls from CF7 ?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @t_dev

    I am sorry about the issue you are experiencing and I am happy to assist you with this.
    I have a couple of questions that may help with finding the issue behind this.
    Is WPML extension activated in Performance>Extension? Are you using CDN? Are you on Apache or nginx, and are you using any custom Access-Control-Allow-Headers rules in nginx.conf/.htaccess?
    Can you please also share your website URL?
    Have you tried adding the Additional home URLs: in Performance>Page Cache>Aliases and add domain2.com?
    Thanks!

    Thread Starter T_Dev

    (@t_dev)

    Hello @vmarko

    Thank you for your assistance.

    1. WPML Extension is not activated, it’s a “pro” version feature.
    We are willing to upgrade, but I cannot find information anywhere about what is it used for or why or who should use it. Can you elaborate about this feature?

    2. We are not using a CDN service
    3. The server is NGINX based.
    4. We are not using Access-Control rules in .htaccess file.
    5. Is there a way to share the URL of our website in private ?
    6. Following your instructions, I added “domain2.com” to
    Performance > Page Cache > Alias and enabled “Cache alias hostnames”.

    It looks like it solved the CORS problem but now the form is being blocked by “SPAM” error.
    { … ,”status”:”spam”,”message”:”There was an error trying to send your message. Please try again later.”, … }

    The form works and the spam error disappears only if I disable W3TC.

    Thank you kindly

    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @t_dev

    Does the issue persist if you exclude a page from being cached?
    Thanks!

    Thread Starter T_Dev

    (@t_dev)

    Yes.

    I tried that and got the same result, “Spam” error message from the CF7 form.

    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @t_dev

    Thank you for the information.
    I was not able to replicate this. You can drop us a note via the plugin in Performance>Support and share your website URL privately so we can check this.
    Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Contact Form 7 blocked by CORS. Multilingual site WPML + domain per language’ is closed to new replies.