4

I am trying to implement Push Notifications for Google Chrome. I want to register service worker from a different domain.

Example: Service Worker Code is located at: https://example.com/

I want to register the service worker (which is located at above domain) from a different domain: https://example2.com/

Is there any way to achieve the same. Because when I try to include the service worker page (example) as an iFrame, the service worker throws an error while registering

"Uncaught (in promise) DOMException: Registration failed - permission denied"

1
  • we were able to solve this problem by showing https://example.com in a new popup window with window.open. not a perfect solution but better than nothing Commented Dec 10, 2015 at 15:10

1 Answer 1

2

This does not seem possible as a SecurityError exception would be included in the rejected Promise if the origin of scriptURL is not client's origin. See the spec on the Registration Algorithm.

Even if possible, there would be few advantages to do so as the service worker's scope, a URL, must have the same origin as the page that registers the service worker.

About the iFrame, there are restrictions in place to prevent you from throwing an https: on an http: page and using that to register a service worker. See DOMException when registering service worker inside an https iframe.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.