ring

kwladyka 2019-04-02T14:30:04.017100Z

Who and why / why not use nginx on top of ring server?

kwladyka 2019-04-02T14:31:06.017800Z

Personally I am thinking about it because of CORS purpose, but on the other hand maybe it is better to implement it in the app. Not sure.

kwladyka 2019-04-02T14:32:12.018400Z

I know we have https://github.com/r0man/ring-cors but it just doesn’t work for me. Nothing is happening.

(wrap-cors :access-control-allow-origin [#"<http://dev.localhost:9500>"]
                 :access-control-allow-headers ["Content-Type" "User-Agent"]
                 :access-control-allow-methods [:options :get :post])
curl -v -i -H "Origin: <http://dev.localhost:9500>" -X DELETE <http://dev.localhost:8080/authorize>                 Tue Apr  2 16:23:06 2019
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to dev.localhost (127.0.0.1) port 8080 (#0)
&gt; DELETE /authorize HTTP/1.1
&gt; Host: dev.localhost:8080
&gt; User-Agent: curl/7.54.0
&gt; Accept: */*
&gt; Origin: <http://dev.localhost:9500>
&gt;
&lt; HTTP/1.1 200 OK
HTTP/1.1 200 OK
&lt; Set-Cookie: auth-session=4594d762-8b71-42ed-bdb1-a27575410196;Path=/;HttpOnly
Set-Cookie: auth-session=4594d762-8b71-42ed-bdb1-a27575410196;Path=/;HttpOnly
&lt; Content-Length: 3
Content-Length: 3
&lt; Server: http-kit
Server: http-kit
&lt; Date: Tue, 02 Apr 2019 14:23:33 GMT
Date: Tue, 02 Apr 2019 14:23:33 GMT

&lt;
* Connection #0 to host dev.localhost left intact
foo⏎

kwladyka 2019-04-02T14:32:31.019Z

it should be rejected, because :delete is not in allowed methods

kwladyka 2019-04-02T14:36:50.019400Z

It doesn’t add headers with -X OPTIONS

kwladyka 2019-04-02T15:00:31.020400Z

(ring.middleware.cors/allow-request? {:headers {"origin" "<http://dev.localhost>"}
                                        :request-method :options}
                                       {:access-control-allow-origin [#"<http://dev.localhost>"]
                                        ;:access-control-allow-headers #{"Content-Type" "User-Agent"}
                                        :access-control-allow-methods #{:options :get :post}
                                        })
return false hmm

kwladyka 2019-04-02T15:03:47.020800Z

oh I see, it looks like ring-cors use forbidden header access-control-request-method

kwladyka 2019-04-02T15:05:19.021200Z

solved…. well, it will be easier to write my own wrapper on this

kwladyka 2019-04-02T15:07:03.021700Z

or use nginx on top of ring, because of no good support for this. What is your choice?

kwladyka 2019-04-02T15:16:22.022100Z

well… probably I will do it on nginx 🙂