Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ring-cors breaks 404 routes when origin header is specified #10

Open
chenfisher opened this issue Apr 2, 2015 · 4 comments
Open

ring-cors breaks 404 routes when origin header is specified #10

chenfisher opened this issue Apr 2, 2015 · 4 comments

Comments

@chenfisher
Copy link

Hi,

When a request contains the 'origin' header - ring-cores sets a response map even if the original response was nil (when route not found) thus making the server return 200 status code instead of 404.

I believe it's the same issue as #5 , which I see was not merged in and is now obsolete to due code change.

Thanks

@r0man
Copy link
Owner

r0man commented Apr 2, 2015

Issue #5 should be covered by this I think:
https://github.com/r0man/ring-cors/blob/master/test/ring/middleware/cors_test.clj#L127
If this is not working as expected a patch with test is welcome!

@chenfisher
Copy link
Author

@r0man,

I think you have a problem with your test. You're missing:
:access-control-allow-methods [:get]
so the test passes while it shouldn't pass.

Test should probably be:

(deftest test-no-cors-header-when-handler-returns-nil
  (is (nil? ((wrap-cors (fn [_] nil)
                        :access-control-allow-origin #".*example.com"
                        :access-control-allow-methods [:get])
             {:request-method
              :get :uri "/"
              :headers {"origin" "http://example.com"}}))))

@r0man
Copy link
Owner

r0man commented Apr 6, 2015

@chenfisher I just pushed ring-cors "0.1.7-SNAPSHOT" to Clojars.
Can you confirm this fixes your problem?

@ioRekz
Copy link

ioRekz commented Nov 27, 2015

I'm not sure this is directly related to that issue but I have the following error

java.lang.NullPointerException: Ring handler returned nil

when I add an origin header to a curl request.
I'm not sure if I'm doing something wrong or immutant or the cors handler
A bit more stack trace

java.lang.NullPointerException: Ring handler returned nil
    at immutant.web.internal.undertow$create_http_handler$reify__4809.handleRequest(undertow.clj:133) ~[na:na]
    at org.projectodd.wunderboss.web.async.websocket.UndertowWebsocket$2.handleRequest(UndertowWebsocket.java:96) ~[wunderboss-web-1.x.incremental.229.jar:na]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants