Skip to content

@angular/pwa show register service worker with relative path #11848

Closed

Description

@CarstenLeue

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request

Command (mark with an x)

- [ ] new
- [ ] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [x] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Versions

Angular CLI: 6.1.3
Node: 8.11.2
OS: win32 x64
Angular: 6.1.2
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router, service-worker

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.6.8
@angular-devkit/build-angular     0.6.8
@angular-devkit/build-optimizer   0.6.8
@angular-devkit/core              0.7.3
@angular-devkit/schematics        0.7.3
@angular/cli                      6.1.3
@angular/pwa                      0.7.3
@ngtools/webpack                  6.0.8
@schematics/angular               0.7.3
@schematics/update                0.7.3
rxjs                              6.2.2
typescript                        2.7.2
webpack                           4.8.3

Repro steps

Running ng add @angular/pwd registers the service worker like so:

ServiceWorkerModule.register('/ngsw-worker.js')

This assumes that the application binaries are loaded from root.

However the build command ng build accepts the --base-href options with allows to set a base URL. The service worker should be loaded relative to this URL (just like the other static resources).

This could e.g. be done by registering the worker like this instead:

ServiceWorkerModule.register('ngsw-worker.js')

Desired functionality

Register the service worker, so it works with the --base-href option.

Mention any other details that might be useful

Activity

  1. added this to the needsTriage milestone on Aug 10, 2018
  2. gkalpak commented on Aug 13, 2018

    @gkalpak
    Member

    This has been fixed in #11200. The fix is included in 6.2.0-beta.0 (but not on 6.1.x).

  3. angular-automatic-lock-bot commented on Sep 8, 2019

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  4. locked and limited conversation to collaborators on Sep 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions