Trouble with CORS preflight request

Hi All,

I am having trouble integrating one of our REST API. When making a POST request from composer I am geting the following error in the test

Error: TypeError: Failed to fetch. Does the server allow CORS?status: undefined

Resource settings for Create record (POST)
Resource URL: https://[redacted]/sirocco/sms-voice-demo
Relative path: /send

In our server, we are getting a pre-flight request (OPTIONS) like so:

OPTIONS /sirocco/sms-voice-demo/send?msisdn=124&message=124 HTTP/1.1" 200 0 "" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36" "-"

And this is the response I am sending to the OPTIONS request

  HTTP/1.1 200 OK
  Server: openresty
  Date: Thu, 23 Jul 2020 10:14:42 GMT
  Content-Type: application/octet-stream
  Content-Length: 0
  Connection: keep-alive
  Access-Control-Allow-Methods: POST, GET, OPTIONS, DELETE
  Access-Control-Max-Age: 86400

Any hint ?


It’s not necessarily cors issue. I’d suggest you take a look at the requests in browser console and see if it’s truly a cors issue.

Thanks for the hint

Access to fetch at 'https://[redacted]/sirocco/sms-voice-demo/send?msisdn=f&message=f' from origin '' has been blocked by CORS policy: Request header field content-type is not allowed by Access-Control-Allow-Headers in preflight response.

I added this header and everything works now

@Luis_Gasca what did you excatly add to the header (and to which header - do you mean the request header)?

Likely if their backend required headers for authentication, that was the missing header they added. It would depend on your backend and what sort of headers it requires.