Using Batman Across Subdomains

Skip to first unread message

Aug 5, 2012, 5:07:12 PM8/5/12

I have an api that I would like to consume using Batman. It's a rails app running on and the batman site would be running on Is it possible to configure Batman to point to It looks like it always defaults to the current url and I haven't been able to find a way to override that.

Thanks for your help

Nick Small

Aug 8, 2012, 5:17:02 PM8/8/12
Hey Mike,

There's a few things to note here. First, you can override the URL of a model with `url:` and define it as either a function or a string. You can also override `urlPrefix` to just add a prefix to the default URL's.

That said, you're going to run into same origin issues. One way around them is to use JSONP, which you can do by telling your Batman.Requests to use `type: jsonp`. However JSONP only works with GET requests, so that probably won't work.

The other options are to run them on the same domain, or run all your requests through a proxy server. At that point, the default URL's should work fine for you.

Hope that helps,


Mike Emery

Aug 8, 2012, 5:18:01 PM8/8/12
to Nick Small,
Thanks for the help, I will play around with your suggestions.

Mike Emery
Sent with Sparrow

Conrad Decker

Aug 12, 2012, 6:11:45 PM8/12/12
to, Nick Small,
I *believe* you may also be able to utilize CORS to handle calls across different domains. If you have control over and are able to add headers to your HTTP Responses you may be in luck. 

You can take a look here and here for some more information. That said, I haven't actually tried to implement it so I'm not sure how easy it is :) 

Would love to hear how you make out though if you head down that road. 


Dec 4, 2014, 5:54:33 PM12/4/14
I know this is super old and batman is no longer supported, but did you figure this out? I'm trying to do something similar, but haven't figured out how

Mike Emery

Dec 5, 2014, 2:12:14 AM12/5/14

I never did, no

Dec 5, 2014, 8:30:14 AM12/5/14
I was eventually able to get this working. Essentially, you need to set @urlPrefix as well as urlPrefix in your Model.

Here's a thread that helped me when I was looking to do the same:!topic/batmanjs/ILmsYrTwIQw as well as a GitHub issue that I opened that has an explanation as to why:

Hope that helps.
Reply all
Reply to author
0 new messages