-
Notifications
You must be signed in to change notification settings - Fork 24.8k
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
Service Worker Http Error 504 When Build Using --base-href=./ (Dynamic Base Href) #25055
Comments
Currently, the SW needs to know the absolute URL to the files. Why do you need a "generic" version? |
@gkalpak : I need SW to handle the URL files as an relative path, not absolute path. There are case where in my client environment, the app deployed as any name they want, let say clientApp1. Then from their internal network, the client only could access the application using this url : https://some.domain.name/clientApp1, but from external network (or internet), the client only could access the application using this url : https://some.domain.name/esb/frontend/clientApp1 due to their environment infrastructure have ESB or any other web server routing for their own reason (mostly because security). |
I see. I think it makes sense. Basically, this is a feature request to support relative paths in AFAICT, that would affect |
@gkalpak : Thank you for your understanding. It's there anything I could do to fasten the development of this feature? Since this feature is critical for my application. |
Pull requests usually help 😉 |
@gkalpak : sounds challenging, so how do I dive in to add this feature? TBH, this is a useful feature, because it will make our angular application more flexible in deployment, rather than do every build for every deployment. |
Yes, it is challenging (especially if you are not familiar with the You can find the built code that (I think) adds support for relative I fixed a couple of other minor issues I stumbled upon, but the main fix is about getting relative URLs to work in This is not in a PR-ready state, of course. This is the built artifact produced by the source code. To make a PR, one would have to port the changes from the diff to the actual source files and write some tests 😁 I don't have time to clean this up and submit a proper PR, but if you or anyone else feels like helping out, you have a good starting point. (I understand you might be less incentivised now 😁) |
@willy-juisan, could you at least try it out and let me know if it actually works (so someone else (or me) can turn it into a PR)? |
@gkalpak Hi, I'm facing an issue in service worker. I'm using angular i18n in my project and it has two build with Maybe it happens due to both the service workers runs simultaneously due to same domain. Please help me to resolve the issue Thanks in Advance |
@sheikalthaf, you didn't provide enough info for me to fully understand the problem, but it sounds like it doesn't fall into the bug report or feature request category. GitHub issues are not suitable for support requests, please repost your issue on StackOverflow using tag (If you think there is a bug in Angular or want to request a feature, please open a new issue and provide all the necessary details, including a minimal reproduction.) If you are wondering why we don't resolve support issues via the issue tracker, please check out this explanation. |
@gkalpak I've created a thread on StackOverflow with a similar problem. Could you please take a look at it? |
…ing --baseHref=./ Closes angular#25055 Closes angular#30505
…ing --baseHref=./ Closes angular#25055 Closes angular#30505
This is in preparation of enabling the ServiceWorker to handle relative paths in `ngsw.json` (as discussed in angular#25055), which will require normalizing URLs in other parts of the ServiceWorker.
In some cases, it is useful to use a relative base href in the app (e.g. when an app has to be accessible on different URLs, such as on an intranet and the internet - see angular#25055 for a related discussion). Previously, the Angular ServiceWorker was not able to handle relative base hrefs (for example when building the with `--base-href=./`). This commit fixes this by normalizing all URLs from the ServiceWorker configuration wrt the ServiceWorker's scope. Fixes angular#25055
This is in preparation of enabling the ServiceWorker to handle relative paths in `ngsw.json` (as discussed in angular#25055), which will require normalizing URLs in other parts of the ServiceWorker.
In some cases, it is useful to use a relative base href in the app (e.g. when an app has to be accessible on different URLs, such as on an intranet and the internet - see angular#25055 for a related discussion). Previously, the Angular ServiceWorker was not able to handle relative base hrefs (for example when building the with `--base-href=./`). This commit fixes this by normalizing all URLs from the ServiceWorker configuration wrt the ServiceWorker's scope. Fixes angular#25055
This is in preparation of enabling the ServiceWorker to handle relative paths in `ngsw.json` (as discussed in angular#25055), which will require normalizing URLs in other parts of the ServiceWorker.
In some cases, it is useful to use a relative base href in the app (e.g. when an app has to be accessible on different URLs, such as on an intranet and the internet - see angular#25055 for a related discussion). Previously, the Angular ServiceWorker was not able to handle relative base hrefs (for example when building the with `--base-href=./`). This commit fixes this by normalizing all URLs from the ServiceWorker configuration wrt the ServiceWorker's scope. Fixes angular#25055
This is in preparation of enabling the ServiceWorker to handle relative paths in `ngsw.json` (as discussed in angular#25055), which will require normalizing URLs in other parts of the ServiceWorker.
In some cases, it is useful to use a relative base href in the app (e.g. when an app has to be accessible on different URLs, such as on an intranet and the internet - see angular#25055 for a related discussion). Previously, the Angular ServiceWorker was not able to handle relative base hrefs (for example when building the with `--base-href=./`). This commit fixes this by normalizing all URLs from the ServiceWorker configuration wrt the ServiceWorker's scope. Fixes angular#25055
This is in preparation of enabling the ServiceWorker to handle relative paths in `ngsw.json` (as discussed in angular#25055), which will require normalizing URLs in other parts of the ServiceWorker.
In some cases, it is useful to use a relative base href in the app (e.g. when an app has to be accessible on different URLs, such as on an intranet and the internet - see angular#25055 for a related discussion). Previously, the Angular ServiceWorker was not able to handle relative base hrefs (for example when building the with `--base-href=./`). This commit fixes this by normalizing all URLs from the ServiceWorker configuration wrt the ServiceWorker's scope. Fixes angular#25055
In some cases, it is useful to use a relative base href in the app (e.g. when an app has to be accessible on different URLs, such as on an intranet and the internet - see angular#25055 for a related discussion). Previously, the Angular ServiceWorker was not able to handle relative base hrefs (for example when building the with `--base-href=./`). This commit fixes this by normalizing all URLs from the ServiceWorker configuration wrt the ServiceWorker's scope. Fixes angular#25055
In some cases, it is useful to use a relative base href in the app (e.g. when an app has to be accessible on different URLs, such as on an intranet and the internet - see #25055 for a related discussion). Previously, the Angular ServiceWorker was not able to handle relative base hrefs (for example when building the with `--base-href=./`). This commit fixes this by normalizing all URLs from the ServiceWorker configuration wrt the ServiceWorker's scope. Fixes #25055 PR Close #37922
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. |
In some cases, it is useful to use a relative base href in the app (e.g. when an app has to be accessible on different URLs, such as on an intranet and the internet - see angular#25055 for a related discussion). Previously, the Angular ServiceWorker was not able to handle relative base hrefs (for example when building the with `--base-href=./`). This commit fixes this by normalizing all URLs from the ServiceWorker configuration wrt the ServiceWorker's scope. Fixes angular#25055 PR Close angular#37922
I'm submitting a...
Current behavior
Whenever the application load for first time, and then the network goes offline, the service worker couldn't provide the application cache and failed with http error 504 as shown below:
Expected behavior
The service worker could provide the application cache and the application could still be loaded even when the network goes offline.
Minimal reproduction of the problem with instructions
ng new sw2 --routing
cd sw2
ng add @angular/pwa --project sw2
ng build --prod --base-href=./
cd dist
cd sw2
npm install -g http-server
(you can use any server to test this, if you prefer another one)http-server
localhost:8080
(8080 is the default port that http-server use at the time of reporting this issue)What is the motivation / use case for changing the behavior?
I need to build my angular application with dynamic base href, because my application will be deployed as any name context e. g. client1app, client2app, /external/client3app, etc.
The application should be working good even when the network is offline (still loaded correctly with cached resources and data).
Environment
The text was updated successfully, but these errors were encountered: