Cross Domain Ajax Request

143 views
Skip to first unread message

Shadownest

unread,
Nov 29, 2013, 4:38:16 AM11/29/13
to zomb...@googlegroups.com
Hi zombie.js users !

I'm working on a new kind of website essentialy developed in javascript (client and server side).
I've made an API on my server, and of course this API has it's own domain name... which is different from my website !

So when i'm trying to make an ajax request to my API i've got an excellent error which tell me i can't make cross domain request...

So, i ran through the source code and i've found THE file and THE line to edit !

In : /node_modules/zombie/lib/zombie/xhr.js

84 -- if (url.host !== this._window.location.host) {
85 --     throw new HTML.DOMException(HTML.SECURITY_ERR, "Cannot make request to different domain");
86 --  }

You just have to comment the line 85 and it'll work ;)

I'm posting this message because i don't have any github account and it took me half a day to not found the answer on google.

Maybe this can help other zombie users ;)

Have a nice day, and thanks zombie team for your script ;)

Assaf Arkin

unread,
Dec 5, 2013, 9:15:24 PM12/5/13
to Shadownest, zomb...@googlegroups.com
There’s no support for cross domain at the moment, so it behaves like a browser that can’t make cross domain requests.

--
You received this message because you are subscribed to the Google Groups "zombie.js" group.
To unsubscribe from this group and stop receiving emails from it, send an email to zombie-js+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

–––––

Subscribe to Weekend Reading, a newsletter about design, code, startup life and the occasional odd

M Elutovich

unread,
Dec 14, 2013, 12:24:54 PM12/14/13
to zomb...@googlegroups.com, Shadownest
Just to stress what Assaf said, browsers are not supposed to allow cross domain requests; they are a security issue.� So even though you've worked around this for zombie, how will your clients use it?

However, there is a bug in those lines of code, which I've pointed out before that it is using host and not hostname, so even to the same address but a different port is also coming up with the error.

On 12/5/2013 9:15 PM, Assaf Arkin wrote:
There�s no support for cross domain at the moment, so it behaves like a browser that can�t make cross domain requests.

Hi zombie.js users !

I'm working on a new kind of website essentialy developed in javascript (client and server side).
I've made an API on my server, and of course this API has it's own domain name... which is different from my website !

So when i'm trying to make an ajax request to my API i've got an excellent error which tell me i can't make cross domain request...

So, i ran through the source code and i've found THE file and THE line to edit !

In :�/node_modules/zombie/lib/zombie/xhr.js

84 -- if (url.host !== this._window.location.host) {
85 -- � � throw new HTML.DOMException(HTML.SECURITY_ERR, "Cannot make request to different domain");
86 -- �}

You just have to comment the line 85 and it'll work ;)

I'm posting this message because i don't have any github account and it took me half a day to not found the answer on google.

Maybe this can help other zombie users ;)

Have a nice day, and thanks zombie team for your script ;)
--
You received this message because you are subscribed to the Google Groups "zombie.js" group.
To unsubscribe from this group and stop receiving emails from it, send an email to zombie-js+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

�����

Subscribe to Weekend Reading, a newsletter about design, code, startup life and the�occasional odd

Reply all
Reply to author
Forward
0 new messages