简体   繁体   English

Web 推送通知 - 多个子域问题?

[英]Web Push Notifications - multiple sub-domains issue?

I just developed Web Push Notifications, but I've got a problem.我刚刚开发了 Web 推送通知,但遇到了问题。

My website has multiple sub-domains.我的网站有多个子域。 For example:例如:

(1) root - www.example.com (2) sub - www.data.example.com (3) sub - www.cool.example.com (1) root - www.example.com (2) sub - www.data.example.com (3) sub - www.cool.example.com

As you could understand, every time when I visit cool.example.com, browser wants permissions for the sub-domain, not for root domain.正如您所理解的,每次我访问cool.example.com 时,浏览器都需要子域的权限,而不是根域的权限。 Of course, it's logical but is it possible to ask permissions for root domain regardless of the fact that I've been visited sub-domain?当然,这是合乎逻辑的,但是无论我已经访问过子域,是否可以请求根域的权限?

Where have you placed your service worker ?你把你的 service worker 放在哪里了? It seems like you have different service worker for each sub-domain, correct ?似乎每个子域都有不同的服务人员,对吗? Anyway, if you place your service worker at the root of your website (and maybe have the subscription javascript also run from there), the scope of the worker will be the entire origin (this service worker will receive fetch events for everything on this domain)无论如何,如果您将 Service Worker 放在您网站的根目录(并且可能还从那里运行订阅 javascript),则 Worker 的范围将是整个源(此 Service Worker 将接收此域上所有内容的 fetch 事件)

Read https://developers.google.com/web/fundamentals/primers/service-workers/ for more information阅读https://developers.google.com/web/fundamentals/primers/service-workers/了解更多信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM