Title: Feature: Ability to force cors mode for some asset/data groups in service worker · Issue #47729 · angular/angular · GitHub
Open Graph Title: Feature: Ability to force cors mode for some asset/data groups in service worker · Issue #47729 · angular/angular
X Title: Feature: Ability to force cors mode for some asset/data groups in service worker · Issue #47729 · angular/angular
Description: Which @angular/* package(s) are relevant/related to the feature request? service-worker Description When using resources from a cross origin, by default fetch() is using cors mode but it's not the case when using and other media el...
Open Graph Description: Which @angular/* package(s) are relevant/related to the feature request? service-worker Description When using resources from a cross origin, by default fetch() is using cors mode but it's not the ...
X Description: Which @angular/* package(s) are relevant/related to the feature request? service-worker Description When using resources from a cross origin, by default fetch() is using cors mode but it's not ...
Opengraph URL: https://github.com/angular/angular/issues/47729
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Feature: Ability to force cors mode for some asset/data groups in service worker","articleBody":"### Which @angular/* package(s) are relevant/related to the feature request?\n\nservice-worker\n\n### Description\n\nWhen using resources from a cross origin, by default `fetch()` is using `cors` mode but it's not the case when using `\u003cimg>` and other media element, or `url()` in CSS, browser defaults to `no-cors` and is able to use opaque response.\r\nFor HTML element, it's possible to force `cors` mode with the [`crossorigin`](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin) attribute, but it's not possible in CSS.\r\nEven when server is configured correctly for CORS, it will usually not responds any CORS headers when the request is made in `no-cors` mode.\r\n\r\nIn Service Worker, when handling a request to a different origin in `no-cors` mode, the response will be considered opaque and can't cached or at least not \"safely\" in a performance strategy because it will also cache error response (as stated in [documentation](https://angular.io/guide/service-worker-config#cacheopaqueresponses)).\r\nHaving the possibility to force `cors` mode for specific url patterns that we know are correctly configured and will handle CORS could ease the use of `performance` strategy and offline use-case when cross origin resources are involved.\r\n\r\nIt might be similar to #38907 (and PR #24510) but with ability to specify request option only on a group.\n\n### Proposed solution\n\nAdd an option for AssetGroup and DataGroup to force the group to be requested using `cors` mode when fetched.\r\nIt might be interesting in some case to also be able to pass a `credentials` option.\r\n\r\nWith an option specific on each group, it's really an opt-in for chosen url patterns, and it will not affects anything else.\n\n### Alternatives considered\n\nI don't really see any. I've tried the alternative proposed by documentation, which is to use `freshness` strategy, but as SW will not differentiate valide opaque response and error, it will cache error and introduce unexpected behavior when offline. Also opaque response have negative impact on the estimation usage of the Storage API.","author":{"url":"https://github.com/jviolas","@type":"Person","name":"jviolas"},"datePublished":"2022-10-11T11:06:31Z","url":"https://github.com/angular/angular/issues/47729"}
| react-profiling | 0 |
| react-import-map | react,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-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:b0db75bc-b2fe-a9b1-6eb1-88b2129ae86a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9E8E:19F84C:1178242:16621BC:6B010772 |
| html-safe-nonce | 22fdecab9d5402964020bcdc99f97c7f3c14f7fd79df97bb7fc3cdc2fb263be7 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RThFOjE5Rjg0QzoxMTc4MjQyOjE2NjIxQkM6NkIwMTA3NzIiLCJ2aXNpdG9yX2lkIjoiNTQ4MDczNjM2ODY4NDUwMDg1MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 9430e55a2ede6d10a0262ad879f9dc20fb55fbe0a258edc108155d559297c5f7 |
| hovercard-subject-tag | issue:1404446115 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular/47729/issue_layout |
| twitter:image | https://opengraph.githubassets.com/5459fe4b442344ac2747a02fe4cdefded67234fca0f91af9b4455c3d8b7c45b9/angular/angular/issues/47729 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/5459fe4b442344ac2747a02fe4cdefded67234fca0f91af9b4455c3d8b7c45b9/angular/angular/issues/47729 |
| og:image:alt | Which @angular/* package(s) are relevant/related to the feature request? service-worker Description When using resources from a cross origin, by default fetch() is using cors mode but it's not the ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jviolas |
| hostname | github.com |
| expected-hostname | github.com |
| None | cb7fa109eca7d4156c889f474306b0e91336055e9adf8fd4684b61e49094d124 |
| turbo-cache-control | no-preview |
| go-import | github.com/angular/angular git https://github.com/angular/angular.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 24195339 |
| octolytics-dimension-repository_nwo | angular/angular |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 24195339 |
| octolytics-dimension-repository_network_root_nwo | angular/angular |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 2b59d31a4e44f08b7af67a4b67f8fd0af3befe2a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width