René's URL Explorer Experiment


Title: Add ability to set URL for ngsw.json at runtime · Issue #51457 · angular/angular · GitHub

Open Graph Title: Add ability to set URL for ngsw.json at runtime · Issue #51457 · angular/angular

X Title: Add ability to set URL for ngsw.json at runtime · Issue #51457 · angular/angular

Description: Which @angular/* package(s) are relevant/related to the feature request? service-worker Description TL;DR: We cannot serve ngsw-worker.js and ngsw.json from the same origin, so we'd like a way to configure where ngsw.json is fetched from...

Open Graph Description: Which @angular/* package(s) are relevant/related to the feature request? service-worker Description TL;DR: We cannot serve ngsw-worker.js and ngsw.json from the same origin, so we'd like a way to c...

X Description: Which @angular/* package(s) are relevant/related to the feature request? service-worker Description TL;DR: We cannot serve ngsw-worker.js and ngsw.json from the same origin, so we'd like a way ...

Opengraph URL: https://github.com/angular/angular/issues/51457

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Add ability to set URL for ngsw.json at runtime","articleBody":"### Which @angular/* package(s) are relevant/related to the feature request?\r\n\r\nservice-worker\r\n\r\n### Description\r\n\r\nTL;DR: We cannot serve `ngsw-worker.js` and `ngsw.json` from the same origin, so we'd like a way to configure where `ngsw.json` is fetched from.\r\n\r\nOur setup requires us to serve the application (i.e files produced by `ng build`) from an external CDN. The CDN URL and path cannot be known at build-time, and is set by the server when the index file is rendered (e.g with [Thymeleaf](https://www.thymeleaf.org)). Think:\r\n\r\n```html\r\n// index.html\r\n\u003cscript>\r\n  window.APP_CONFIG = {\r\n    cdnUrl: [[${CDN_URL}]]\r\n  };\r\n\u003c/script>\r\n\r\n\u003cscript th:src=\"@{${CDN_URL}+'polyfills.js'}\">\u003c/script>\r\n\u003cscript th:src=\"@{${CDN_URL}+'runtime.js'}\">\u003c/script>\r\n\u003cscript th:src=\"@{${CDN_URL}+'main.js'}\">\u003c/script>\r\n```\r\n\r\nWhen trying to add  `@angular/service-worker` for offline support into the mix, we run into the issue that the `ngsw-worker.js` script cannot be served from the CDN like other files, because of browser restrictions.\r\n\r\nWe *can* work around this by having the `ngsw-worker.js` be served from the page origin. However, we'd still like for the `ngsw.json` manifest to be served together with the rest of the app from the CDN. And this is the issue. There is no way to tell the service worker to fetch the manifest from a different path/url.\r\n\r\n### Proposed solution\r\n\r\nAdd a *runtime* config property that allows to override the default `ngsw.json` path. For example: \r\n\r\n```typescript\r\nServiceWorkerModule.register(\"ngsw-worker.js\", {\r\n\t// ...\r\n\tmanifestUrl: `${window.APP_CONFIG.CDN_URL}/ngsw.json`,\r\n}),\r\n```\r\n\r\nNote that for our setup, the CDN URL is not known at build-time, so it cannot be a part of `ngsw-config.json`.\r\n\r\nEDIT:\r\nAnother possible solution would be something like:\r\n```typescript\r\nServiceWorkerModule.register(\"ngsw-worker.js\", {\r\n\t// ...\r\n\tngswOrigin: \"sw-scope\" | \"import-meta\",\r\n}),\r\n```\r\n...where `\"sw-scope\"` would be default (and the way it works right now), and `\"import-meta\"` would become a URL that is based on where the `main.js` script is loaded from. Possibly based on `import.meta.url`.\r\n\r\nEDIT2:\r\nI forgot to add: If the `ngsw.json` is served from an external URL, then there must also be a way to tell the service worker that the URL:s inside of it are relative. Like so:\r\n\r\n```json\r\n// https://the.cdn/path/to/ngsw.json\r\n{\r\n  \"assetGroups\": [\r\n    {\r\n      \"urls\": [\r\n          \"main.js\" // Service Worker should interpret this as https://the.cdn/path/to/main.js\r\n        ],\r\n    }\r\n  ],\r\n}\r\n```\r\n\r\n### Alternatives considered\r\n\r\nOne alternative we tried was to serve `ngsw.json` from the page origin (i.e the same as `ngsw-worker.json`).\r\n\r\nHowever this is not ideal, as the CDN files are deployed more or less independently from the index page.","author":{"url":"https://github.com/anhallbe","@type":"Person","name":"anhallbe"},"datePublished":"2023-08-22T07:06:08Z","url":"https://github.com/angular/angular/issues/51457"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:ca797ba5-0875-44d3-074c-2a23bce0911b
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idD65C:1CEA6F:FF8604:1525756:6B010864
html-safe-nonce6671e0bcd6660ed9d56fed745c046fa80ebe421a2600eded9f774ca6d5525d6e
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENjVDOjFDRUE2RjpGRjg2MDQ6MTUyNTc1Njo2QjAxMDg2NCIsInZpc2l0b3JfaWQiOiI3ODU4NTY1ODczMDQ3NTA0OTk2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac4955aada6d1cf410b3446cf3d3c51de96f9ce6f5063fc60524ff9be1896b4626
hovercard-subject-tagissue:1860752854
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular/51457/issue_layout
twitter:imagehttps://opengraph.githubassets.com/c258373adfcf22b6066d6fd08b9ec04fff4cff440f3bb99d1a0480ca2938644a/angular/angular/issues/51457
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/c258373adfcf22b6066d6fd08b9ec04fff4cff440f3bb99d1a0480ca2938644a/angular/angular/issues/51457
og:image:altWhich @angular/* package(s) are relevant/related to the feature request? service-worker Description TL;DR: We cannot serve ngsw-worker.js and ngsw.json from the same origin, so we'd like a way to c...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameanhallbe
hostnamegithub.com
expected-hostnamegithub.com
Nonecb7fa109eca7d4156c889f474306b0e91336055e9adf8fd4684b61e49094d124
turbo-cache-controlno-preview
go-importgithub.com/angular/angular git https://github.com/angular/angular.git
octolytics-dimension-user_id139426
octolytics-dimension-user_loginangular
octolytics-dimension-repository_id24195339
octolytics-dimension-repository_nwoangular/angular
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id24195339
octolytics-dimension-repository_network_root_nwoangular/angular
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release2b59d31a4e44f08b7af67a4b67f8fd0af3befe2a
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/angular/angular/issues/51457#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fangular%2Fangular%2Fissues%2F51457
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fangular%2Fangular%2Fissues%2F51457
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=angular%2Fangular
Reloadhttps://github.com/angular/angular/issues/51457
Reloadhttps://github.com/angular/angular/issues/51457
Reloadhttps://github.com/angular/angular/issues/51457
angularhttps://github.com/angular
angularhttps://github.com/angular/angular
Codehttps://github.com/angular/angular
Issues835 (835)https://github.com/angular/angular/issues
Pull requests141 (141)https://github.com/angular/angular/pulls
Discussionshttps://github.com/angular/angular/discussions
Actionshttps://github.com/angular/angular/actions
Projectshttps://github.com/angular/angular/projects
Security and quality40 (40)https://github.com/angular/angular/security
Insightshttps://github.com/angular/angular/insights
https://github.com/angular/angular
New issuehttps://github.com/login?return_to=https://github.com/angular/angular/issues/51457
New issuehttps://github.com/login?return_to=https://github.com/angular/angular/issues/51457
Add ability to set URL for ngsw.json at runtimehttps://github.com/angular/angular/issues/51457#top
area: service-workerIssues related to the @angular/service-worker packagehttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22area%3A%20service-worker%22
needsTriagehttps://github.com/angular/angular/milestone/83
https://github.com/anhallbe
anhallbehttps://github.com/anhallbe
on Aug 22, 2023https://github.com/angular/angular/issues/51457#issue-1860752854
Thymeleafhttps://www.thymeleaf.org
AndrewKushnirhttps://github.com/AndrewKushnir
area: service-workerIssues related to the @angular/service-worker packagehttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22area%3A%20service-worker%22
on Aug 23, 2023https://github.com/angular/angular/issues/51457#event-10164127644
ngbothttps://github.com/apps/ngbot
needsTriagehttps://github.com/angular/angular/milestone/83
on Aug 23, 2023https://github.com/angular/angular/issues/51457#event-10164127768
https://github.com/JeanMeche
JeanMechehttps://github.com/JeanMeche
on Aug 27, 2025https://github.com/angular/angular/issues/51457#issuecomment-3228568361
#63364https://github.com/angular/angular/pull/63364
https://angular.dev/ecosystem/service-workershttps://angular.dev/ecosystem/service-workers
JeanMechehttps://github.com/JeanMeche
not plannedhttps://github.com/angular/angular/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Anot-planned
on Aug 27, 2025https://github.com/angular/angular/issues/51457#event-19370870534
https://github.com/apps/angular-automatic-lock-bot
angular-automatic-lock-bothttps://github.com/apps/angular-automatic-lock-bot
on Sep 27, 2025https://github.com/angular/angular/issues/51457#issuecomment-3340847598
automatic conversation locking policyhttps://github.com/angular/angular/blob/f0fbced1c55bc8b8ed9df01cea99df42f3e7eae3/contributing-docs/auto-issue-locking.md
angular-automatic-lock-bothttps://github.com/apps/angular-automatic-lock-bot
on Sep 27, 2025https://github.com/angular/angular/issues/51457#event-19954774119
Sign up for freehttps://github.com/signup?return_to=https://github.com/angular/angular/issues/51457
Sign in to commenthttps://github.com/login?return_to=https://github.com/angular/angular/issues/51457
area: service-workerIssues related to the @angular/service-worker packagehttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22area%3A%20service-worker%22
needsTriageNo due datehttps://github.com/angular/angular/milestone/83
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.