gpt4 book ai didi

javascript - 如何将外部网站链接到内部 javascript 页面

转载 作者:行者123 更新时间:2023-11-28 07:21:39 24 4
gpt4 key购买 nike

我有一个网站,我们称之为 example.com ,它托管在外部托管提供商处。在网站上我有一个页面 http://example.com/msg.php需要从 Intranet 站点引用 JavaScript,比如说在 example_intranet.com 上运行,所以我有一个脚本引用,例如..

 <script src="http://example_intranet.com/js/messaging.js" type="text/javascipt">

我了解跨域安全问题,并已在 example.com 网站和页面上设置了必要的 CORS。

当您访问http://example.com/msg.php时从公司网络外部 (example_intranet.com) 一切都按预期工作,但是当您从网络内部(内部)访问同一页面时,该页面似乎无法解析 javascript include ..

关于如何解决这个问题有什么建议吗?那就是能够让引用javascirpt从网络内部工作。

最佳答案

我猜这是一个 DNS 问题,而不是代码问题。当您在公司网络上时,Intranet URL 域可能会解析为不同的“内部”IP 地址,而当您在公司网络外部时,它可能会解析为公共(public) IP 地址。

理论场景:

When you are in the company network, the intranet URL gets resolved to a local IP, like 192.x.x.x or 10.x.x.x. SO when you visit your page on the external host your machine is trying to find the javascript file using that internal IP, but it might be looking for it inside the network of the external host, and won't find it.

作为实验,尝试更改 javascript 文件的路径以使用该 Intranet URL 的公共(public) IP 而不是域名。

关于javascript - 如何将外部网站链接到内部 javascript 页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30241597/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com