ohler55 / agoo

A High Performance HTTP Server for Ruby
MIT License
912 stars 39 forks source link

CORS issues #106

Closed stas closed 2 years ago

stas commented 2 years ago

Hi there, we tried switching to Agoo a couple of times, both times we'd randomly experience requests failing due to CORS:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://api..... (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). Status code: 400

Unfortunately I could not figure out what could be the issue, but I thought I'd leave this as a feedback for new users if they are looking into giving Agoo a try.

Thank you for open sourcing this btw!!! :bow:

ohler55 commented 2 years ago

That seems like a good option to add. I'll start working on that.

ohler55 commented 2 years ago

Looking into it now. Are you using Agoo as a GraphQL server? If so there is an an example that might help: example/graphql/song.rb.

If not using as a GraphQL server then what are you setting the headers to?

stas commented 2 years ago

@ohler55 we're not using GraphQL. In fact it's a pretty standard RESTful rails app using rack-cors.

ohler55 commented 2 years ago

Ok, so I assume that means you are using the #call() method of the handler. What are you providing as headers?

stas commented 2 years ago

@ohler55 I'm afraid we're not calling anything directly, as the rack-cors takes care of it and the headers needed to fulfill the request response.

The configuration we have is pretty much standard as described in their guide: https://github.com/cyu/rack-cors#rails-configuration

ohler55 commented 2 years ago

Agoo does not add any headers directly for CORS but it does have options for turning on tracing If you are able to turn on some of the debugging information for requests and responses we can see what is being request and sent. From there we can try to determine what middleware layer is setting or not setting the headers.

ohler55 commented 2 years ago

Can this be closed?

stas commented 2 years ago

@ohler55 apologies for the delay with this one, unfortunately we didn't manage to make time to look into this further. I believe we can close it for now. Thanks again for helping figure things out! :bow: