Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GWT : separate js + css + images from server

We'd like to have the following configuration :

  • one server is replying to GWT RPC : x.com (the one running Java)
  • another server is serving js / css / images : y.com (for bandwith optimization)

So the main page is : http://x.com/index.html and contains this line: <script type="text/javascript" language="javascript" src="http://**x.com**/my-app.nocache.js"></script>

We're getting a SOP error: Unsafe JavaScript attempt to access frame with URL ...

Any suggestion, help about that ?

like image 452
Marc Polizzi Avatar asked May 20 '11 14:05

Marc Polizzi


2 Answers

Add the following to your gwt.xml:

<add-linker name="xsiframe" />

This will generate slightly different code, that can be loaded cross-origin. Your "host page" will still have to be loaded from the same server you run your GWT-RPC servlets on, to not hit the SOP.

See this FAQ entry (the "xs" linker predates the "xsiframe" one, that latter is now preferred, and could eventually even replace the "std", default linker)

like image 110
Thomas Broyer Avatar answered Oct 26 '22 23:10

Thomas Broyer


You have hit Same Origin Policy which prevents making XMLHTTPRequest to servers other than origin server. This effectively prevents cross-domain GWT-RPC.

The possible workarounds are described in Making cross-site requests:

  1. Run a proxy on your server
  2. Load the JSON response into a <script> tag
like image 31
Peter Knego Avatar answered Oct 26 '22 23:10

Peter Knego