I am using WordPress Contact Form 7 plugin to send message from my mobile application. Of course testing with PostMan worked with no issues but as soon as I tried to post to the endpoint from my mobile application I am getting the following error:

Access to XMLHttpRequest at 'mydomain.com/wp-json/contact-form-7/v1/contact-forms/18/feedback' from origin 'null' has been blocked by CORS policy: Request header field access-control-allow-origin is not allowed by Access-Control-Allow-Headers in preflight response.

1: What does the following part of the error mean?

in preflight response

2: What can I update on my WordPress install to allow the above process to be successful? I have access to the site files and I am able to add a new plugin if that helps.

Below is a screenshot of the headers and their values when I try to hit the endpoint from my local development machine:

    Request URL: mywebsite.com/wp-json/contact-form-7/v1/contact-forms/622/feedback
    Request Method: OPTIONS
    Status Code: 200 OK
    Remote Address:
    Referrer Policy: no-referrer-when-downgrade

    Access-Control-Allow-Credentials: true
    Access-Control-Allow-Headers: Authorization, Content-Type
    Access-Control-Allow-Methods: OPTIONS, GET, POST, PUT, PATCH, DELETE
    Access-Control-Allow-Origin: null
    Access-Control-Expose-Headers: X-WP-Total, X-WP-TotalPages
    Allow: POST
    Connection: keep-alive
    Content-Encoding: gzip
    Content-Type: application/json; charset=UTF-8
    Date: Mon, 06 Jan 2020 03:39:34 GMT
    Link: <mywebsite.com/wp-json/>; rel="https://api.w.org/"
    Server: nginx/1.17.5
    Transfer-Encoding: chunked
    Vary: Accept-Encoding
    Vary: Origin
    X-Content-Type-Options: nosniff
    X-Robots-Tag: noindex

    Accept: */*
    Accept-Encoding: gzip, deflate
    Accept-Language: en-US,en;q=0.9
    Access-Control-Request-Headers: access-control-allow-origin
    Access-Control-Request-Method: POST
    Connection: keep-alive
    Host: mywebsite.com
    Origin: null
    User-Agent: Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Mobile Safari/537.36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.