I'm building a Grape API alongside Sinatra. So far I've been mounting them in separate routes like this:
run Rack::URLMap.new("/" => Frontend::Server.new,
"/api" => API::Server.new)Where the "/api" is served by a Grape app and "/" by a Sinatra app. But I wanted to use subdomains to separate those concerns instead of the actual "sub-URL". Any clues on how to do this?
Thanks in advance for the help.
--
You received this message because you are subscribed to the Google Groups "Grape Framework Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-grape+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
dB. | Moscow - Geneva - Seattle - New York
code.dblock.org - @dblockdotorg - artsy.net - github/dblock
You received this message because you are subscribed to a topic in the Google Groups "Grape Framework Discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ruby-grape/SIIDKJiIYDg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ruby-grape+...@googlegroups.com.
Just to clarify some terms here - it sounds like you might be talking past each other on the CORS front.
When a page "http://example.com/" tries to access a resource "http://subdomain.example.com/", the browser considers that a violation of the famous Same Origin policy.
CORS (Cross-Origin Resource Sharing) is a way around the Same Origin Policy in that it allows servers to allow specific exemptions to the Same Origin Policy.
Grape itself doesn't enable CORS itself, but it's easy to enable CORS with a middleware gem - see the CORS section in Grape's README:
https://github.com/intridea/grape/blob/master/README.md#cors
General information on using CORS to work around the Same Origin Policy:
http://enable-cors.org/
use Rack::Cors do allow do origins '*' resource '*', :headers => :any, :methods => [:get, :post, :options, :delete] end allow do origins '*' resource '/public/*', :headers => :any, :methods => :get end end
In your case, I think that you should be more restrictive about the origins. BTW, did you use rack-cors and still didn't work?