Handling cors preflight Options in Servant

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Handling cors preflight Options in Servant


I used wai-cors middleware (simpleCors function around "Application") to enable simple CORS access. When testing, however, I get 400 error during preflight check. So, I checked around and saw this thread:

The reason I am checking is because of this error I get during preflight check (my original request is a POST with json body - a preflight check is triggered) - please note I have removed host and origin headers below as they are not very relevant - the servant POST handler for /grant handles only JSON post btw:

OPTIONS /grant HTTP/1.1
Host: <removed for posting to this group>
Accept: */*
Accept-Encoding: gzip, deflate, sdch
Accept-Language: en-US,en;q=0.8
Access-Control-Request-Headers: content-type
Access-Control-Request-Method: POST
Origin:  <removed for posting to this group>
Referer:  <removed for posting to this group>
User-Agent: Mozilla/5.0 (iPad; CPU OS 7_0_4 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11B554a <and other stuff which I removed from here...>

HTTP/1.1 400 Bad Request
Connection: keep-alive
Content-Length: 171
Content-Type: text/html; charset-utf-8
Date: Mon, 08 Feb 2016 13:10:53 GMT
Server: Warp/3.2.2