从远程计算机运行 GWT 应用程序
我正在开发一些 GWT 应用程序,某些第三方需要将其导入到他自己的网站中。
我正在开发的应用程序托管在我的机器上,其位置为: http://myMachine.com/app/gwtApp.html
应用程序如下所示:
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link type="text/css" rel="stylesheet" href="http://myMachine.com:8888/app/gwtApp.css">
<title>gwtApp</title>
<script language="javascript" src="http://myMachine.com:8888/app/gwtApp/gwtApp.nocache.js"></script>
</head>
<body>
<div id="app" style="width:240px; height:190px;"></div>
</body>
</html>
注意:我已经编写了一些代理 servlet 只是为了解析我的服务器的 url,正如您所知,默认情况下上面的脚本标记如下所示: ,但我的代理将其转换为:
第三方使用了一些导入机制(jstl import 或其他)只是将上述内容导入到他们的网站(在完全不同的域上),
问题是,他们收到以下 JS 错误,并且应用程序没有呈现任何内容:
Error: Permission denied for <http://172.16.0.87:8888> to get property Window.document from <http://thrid-party_domain.com>.
Source File: http://myMachine.com/app/gwtApp/37A4800286E685E7555FF8DCA66FC4F9.cache.html
Line: 1
Error: Permission denied for <http://myDomain:8888> to get property Window.gwtApp from <http://thrid-party_domain.com>.
Source File: http://myMachine.com/app/gwtApp/37A4800286E685E7555FF8DCA66FC4F9.cache.html
Line: 1463
I am developing some GWT application that some third-part will need to import into his own website.
The application that I am developing consist hosted on my machine which say at:
http://myMachine.com/app/gwtApp.html
the application looks like:
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link type="text/css" rel="stylesheet" href="http://myMachine.com:8888/app/gwtApp.css">
<title>gwtApp</title>
<script language="javascript" src="http://myMachine.com:8888/app/gwtApp/gwtApp.nocache.js"></script>
</head>
<body>
<div id="app" style="width:240px; height:190px;"></div>
</body>
</html>
NOTE: I've written some proxy servlet just to resolve the url againest my server, as you know the script tag above by default looks like:<script language="javascript" src="app/gwtApp/gwtApp.nocache.js"></script>
, but my proxy converted it to :<script language="javascript" src="http://myMachine.com/app/gwtApp/gwtApp.nocache.js"></script>
The third-party uses some import mechanism (jstl import or whatever) just to import the above content into their web site (on completely different domain)
The problem is, they getting the Following JS error and nothing get rendered from the application:
Error: Permission denied for <http://172.16.0.87:8888> to get property Window.document from <http://thrid-party_domain.com>.
Source File: http://myMachine.com/app/gwtApp/37A4800286E685E7555FF8DCA66FC4F9.cache.html
Line: 1
Error: Permission denied for <http://myDomain:8888> to get property Window.gwtApp from <http://thrid-party_domain.com>.
Source File: http://myMachine.com/app/gwtApp/37A4800286E685E7555FF8DCA66FC4F9.cache.html
Line: 1463
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题似乎与 同源策略规则。您的css和javascript文件已从不同的端口发布:8888和80。如果您将css文件的端口更改为80,我相信您不会收到之前的错误。
It looks like problem is related to same origin policy rule. Your css and javascript file has been published from different port : 8888 and 80. If you change the port of css file to 80, I believe you wont get the previous error..