Search code examples
google-chromepush-notificationweb-pushpush-api

Chrome Push Notifications: can't subscribe from sub-path


I'm trying to subscribe to the pushManager, and I can only achieve it while on the root (/) path. If I navigate to any sub path (/mypath), I recieve Unable to subscribe to push. DOMException: Registration failed - no sender id provided.

The problem is that in order to subscribe, it needs to read values from manifest.json, which is in the root of my public directory. For some reason, it's trying to find the manifest.json file from a directory relative to the current path. For example, for /mypath, it will try to fetch the file from mydomain/mypath/manifest.json, while it should always (I believe) try to fetch the file from mydomain/manifest.json.

How can I solve this problem?

Link to related ticket (on a push-notification lib for Meteor I did): https://github.com/taromero/meteor-chrome-push-notifications/issues/1.


Solution

  • Use a slash before the name of the manifest file. The slash denotes that it is has to pick up the file from the root of the domain.

    <link rel="manifest" href="/manifest.json">