r0man / ring-cors

Ring middleware for Cross-Origin Resource Sharing.
http://github.com/r0man/ring-cors
169 stars 44 forks source link

Switched to 0.1.2 from 0.1.1, my app broke... #4

Closed dcj closed 10 years ago

dcj commented 10 years ago

With version 0.1.1, my app included this:

(wrap-cors :access-control-allow-origin #"http://(.*\.)?likestream.net(:\d*)"
                  :access-control-allow-headers ["X-API-Version" "Accept" "Content-Type"]
                  :access-control-allow-methods ["GET" "PUT" "POST" "DELETE"]
                  :access-control-allow-credentials "true")

When I switched to version 0.1.2 (no other change to my code), then the CORS headers are not included in the response to the OPTIONS request.

FYI, my request headers look like this:

Accept:*/*
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Access-Control-Request-Headers:x-api-version, accept
Access-Control-Request-Method:GET
Cache-Control:no-cache
Connection:keep-alive
Cookie:ring-session=fd674f7e-15ad-4aab-bae4-268fcc251b4e
Host:spare03.likestream.net:8080
Origin:http://dcjdev.likestream.net:8090
Pragma:no-cache
Referer:http://dcjdev.likestream.net:8090/
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36    (KHTML, like Gecko) Chrome/36.0.1985.18 Safari/537.36

Is this a bug in my code, or has something changed in ring-cors?

dcj commented 10 years ago

Apparently now the :access-control-allow-methods directive supports (only?) a vector of method keywords? e.g.

:access-control-allow-methods [:get :put :post :delete]

Where before the methods were strings, correct? I vastly prefer the keywords, made this change, and my app is working again.

If this is a breaking API change, perhaps that might be noted in the README/commit for this version?