Hi all! I am running an Elm frontend that talks to a Phoenix backend. They are having trouble communicating. I am getting this error on POST requests:
(1)
[info] OPTIONS /api/v1/users
[error] Invalid preflight CORS request because the header "content-type" is not in :allow_headers
[info] Sent 200 in 17ms
My Corsica Plug config is below in (3). I’ve checked that the request header has the line (2) it should. So I think the request from Elm is OK, but Phoenix is not handing it correctly. I’ve posted all the info on the request in (4).
Any idea what’s going on??
(2)
Access-Control-Request-Headers:content-type
(3)
plug Corsica, origins: ["http://localhost:5000", "https://elm-docviewer.herokuapp.com"],
allow_headers: ["content-type"]
(4)
Request URL:http://localhost:4000/api/v1/users
Request Method:OPTIONS
Status Code:200 OK
Remote Address:127.0.0.1:4000
Referrer Policy:no-referrer-when-downgrade
Response Headers
view source
cache-control:max-age=0, private, must-revalidate
content-length:0
date:Sat, 13 May 2017 16:09:09 GMT
server:Cowboy
x-request-id:ldd9bt0qi67tu87smtfpbr190cc67uh0
Request Headers
view source
Accept:*/*
Accept-Encoding:gzip, deflate, sdch, br
Accept-Language:en-US,en;q=0.8
Access-Control-Request-Headers:content-type
Access-Control-Request-Method:POST
Connection:keep-alive
Host:localhost:4000
Origin:http://localhost:5000
Referer:http://localhost:5000/
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36