-
Notifications
You must be signed in to change notification settings - Fork 12k
ServiceWorker are not using --deploy-url #9753
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Experiencing the same issue here. I'm setting a Angular CLI: 1.7.1 |
This is quite an important bug. Can we maybe remove the |
For anyone reading this, I managed to get around without too much messing around by re-generating the ngsw.json with the following command
in my case
|
@santialbo-actimo does your solution work for CDN urls as well? For example if I set deployUrl to https://cdn.mydomain.com/ |
From looking at docs/design/deployurl-basehref.md, it seems that I am trying to understand the usecase. Wouldn't |
Our cdn is on a different url than the application self. Example: https://myapplication.domain.com/ <- index.html is served by a server (configurations are made on the fly) Thats the reason why i like the different possibilities for basehref and deploy url |
So, other than |
@tfiwm Using an HTML base HREF of |
Sounds great and we will try it ;) How will be the /ngsw-worker.js handled? Based on html base HREF or the APP_BASE_HREF |
This works like a solid solution for my! Checked it and works good and have even more benefits than the solution with the deploy url. Thanks for this technical solution!! |
Can you please also guide where do we set Should we set
and |
We set the cdn base path with --baseHref Why? <base href="MY_CDN_DOMAIN"> -> relative paths in scripts or other assets are getting loaded from there We set the APP_BASE_PATH for our application (routing)-> Here an example with dynamic value export const initAppBaseHref = () => {
return environment.appBaseHref;
};
export const baseHrefProvider: FactoryProvider = {
provide: APP_BASE_HREF,
useFactory: initAppBaseHref
};
providers: [baseHrefProvider] |
I tried this but receiving below error when I deploy the website:
in my AppModule I have added
When I manually edited the Index.html file and replaced
and added CDN to the path of javascript bundles, it started working. I built app with |
your { provide: APP_BASE_HREF, useValue: '/' } -> must return the path to your application base href (necessary for the router) I am using following trick in my environment file
Not sure if this will work with serverside rendering too but in my case it was working with a factoryprovider |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
The service worker is loaded from the base url which is not working if i set a deploy-url
Versions
Repro steps
Observed behavior
Angular uses the base url instead of deploy-url
Desired behavior
The service worker is loaded by following rules:
The text was updated successfully, but these errors were encountered: