-
Notifications
You must be signed in to change notification settings - Fork 12k
ServiceWorker are not using --deploy-url #12322
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
Have you tried using |
Yes I guess that's how I added the service worker. |
Any news about the issue? I'm facing the same problem. I need to build the app using --deploy-url specifically (and not with href) and the urls generated in the service worker do not have the --deploy-url. It should work exactly as @naveedahmed1 explained |
Would love some news about this issue as well, can make a contribution if led in the right direction. I don't see why this would be a large change. Essentially just a one liner adding a prefix to the generated URL using the command line argument value as the prefix...am I right? |
Hi, I am encountering this issue too. So i cant use base-href and i need the deploy url option. Here: https://github.com/angular/angular-cli/blob/master/packages/angular_devkit/build_angular/src/browser/index.ts#L231 |
@Need-To-Learn I fixed this with a custom script that rewrites the index.html created by an It's not pretty, but it works well for me without having to wait for the Angular team to release a fix (which will likely not happen unless someone else puts in the PR since this isn't a high priority). |
+1 here. |
Also causing some issues my side. Our CDN deploy URL is transient too for web assets, so we need manifest and service worker urls to obey --deployUrl. |
@alxhub @IgorMinar - It seems like this one is preventing a lot of users from using the PWA package. Any chance to change the priority for this? |
@lansana Had to do the same with a custom script. |
@alan-agius4 , You have categorized this item as "low frequency", but in fact everybody who uses cdn for deployment and pwa face this issue. Does it make sense to increase priority? |
@Nodarii bumped the frequency. Thanks for highlighting this. |
temporary fix that I'm using:
then after your dist folder is built run - |
Any word on the state of this story? I've been running into issues with this. |
up |
please!!! |
Nothing yet people? this is a high priority. Every time I build my application I have to make changes manually. This is a high priority for me. |
Some notes on this issue: It is important that these files are served from the application root path and not from another domain as this specifies their scope:
I have also noticed that with angular 10.1.3 it is also needed to have the index.html file on the same domain as the application, if not the navigation requests fail, even if ngsw.json has a correct If you also have a scripts.js or styles configured via This behavior seems like a bug in Chrome (85) as it does not occur in Firefox In conclusion, here are the steps to make it all work properly:
|
bump |
Need this feature as well |
@koenig-dominik Hey! Thanks for this summary. I tried something similar but think I made some mistakes during hash calculation. Is there any chance you could upload/post the scripts you use for this so we can compare notes? Could help some others as well. Cheers! I was trying to do this with
|
any idea with lazyloding route?some problem |
With this change we deprecate deployUrl which in many case causes unexpected and undesired behaviour. Such as #12322, #21432 and #6666. This is because one of the drawbacks of deploy Url is that this url needs to be injected all over the bundles. This option was previously introduced to handle application that only assets are hosted on a CDN. This setup is now mostly considered as legacy as it is recommended that the entire application is hosted on a CDN. That said, this legacy behaviour can still be achieved by setting the `baseHref` to the CDN address, while setting the `APP_BASE_HREF` to the application address. Closes #12322 and closes #6666
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. |
Bug Report or Feature Request (mark with an
x
)Command (mark with an
x
)Versions
node: v8.11.4
Repro steps
This is a followup issue from #9753
Recap:
ng build --deploy-url https://cdn.domain.com/
Angular uses the base url instead of deploy-url
#9753 suggests to use
HTML base HREF
ofhttps://cdn.domain.com
and an AngularAPP_BASE_HREF of /
. But this doesn't work as expected.Conclusion
I tested my app with different configurations and below is my conclusion:
Using an HTML base HREF of https://cdn.domain.com and an Angular APP_BASE_HREF of / doesn't work.
Using an HTML base HREF of https://cdn.domain.com and dynamically setting Angular APP_BASE_HREF to mydomain.com works (but has additional issue).
We can set dynamically Angular APP_BASE_HREF:
environment.appBaseHref: window.location.protocol + "//" + window.location.hostname + (window.location.port ? ':' + window.location.port:'')
{ provide: APP_BASE_HREF, useValue: environment.appBaseHref }
Though the second option works, but it introduces another issue, since we have now set the HTML base HREF to our CDN domain, this breaks other libraries that we are using. For example in my case
we are using other libraries such as Firebase Messaging for Push Notifications. When HTML base HREF is set to CDN it doesn't work.
I think we do need support for --deploy-url
Desired functionality
So, when --deploy-url is provided:
/
The text was updated successfully, but these errors were encountered: