获取“脚本” at' https://example.com/webworker.js'无法从Origin www.example.com访问。”即使是Cname重定向www。到主要领域

发布于 2025-01-23 14:44:52 字数 764 浏览 2 评论 0 原文

我会遇到一个问题,如果我访问了我要通过 www.example.com/page 然后浏览器无法初始化网络工人。

根据我的阅读,这是出于安全目的的预期行为。很好,但是我预计有些人会通过

我认为这样做的简单方法是更改​​ www.example.com 从 @ record到cname记录,将所有调用重定向到 https://www.example.com/page 而不是 https://example.com/page

我昨晚做到了,旧记录的TTL只有30m,所以甚至到目前为止,世界上最慢的DNS缓存应该已更新。

但是,如果我尝试通过 www.example.com

我在这里想念什么?最重要的是,我该如何完成这项工作?

I'm getting an issue where if I access a website I'm making via www.example.com/page then the browser fails to initialize the web workers.

From what I've read this is expected behaviour for security purposes. And that's fine, but I anticipate some people will be coming to the site via www.example.com while others will just type in example.com, and I'll need both to be able to access all the site's resources.

I figure the easy way to do this is to change www.example.com from an @ record to a CNAME record, redirecting all calls to https://www.example.com/page instead to https://example.com/page

I did that last night, and the TTL on the old record was only 30m, so even the world's slowest DNS caches should have been updated by now.

But if I try to access the site via www.example.com I'm still getting the same domain origin error.

What am I missing here? And most importantly, how can I make this work?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

醉生梦死 2025-01-30 14:44:52

CNAME记录不是HTTP重定向。

浏览器寻找 www.example.com ,对其进行DNS查找,并告诉基础DNS客户端,IP地址与 example> example.com '相同S,因此它获取示例的IP地址,然后向该IP地址提出http请求,要求 www.example.com

Origin 仍然是 https://www.example.com


将您的HTTP服务器配置为发行 301,以永久移动重定向 www.example.com 而不是。

CNAME records are not HTTP redirects.

The browser looks for www.example.com, makes a DNS lookup for it, and the underlying DNS client gets told that the IP address is the same as example.com's, so it gets example.com's IP address and then makes an HTTP request to that IP address asking for www.example.com.

The origin will still be https://www.example.com.


Configure your HTTP server to issue a 301 Moved Permanently redirect for any requests for www.example.com instead.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文