René's URL Explorer Experiment


Title: Angular Service Worker breaks HTML forms POST submit · Issue #36368 · angular/angular · GitHub

Open Graph Title: Angular Service Worker breaks HTML forms POST submit · Issue #36368 · angular/angular

X Title: Angular Service Worker breaks HTML forms POST submit · Issue #36368 · angular/angular

Description: 🐞 bug report Affected Package The issue is caused by package @angular/service-worker Is this a regression? No Description We have an hybrid stack with old school PHP pages mixed with an Angular SPA, and the Angular app has a wildcard rou...

Open Graph Description: 🐞 bug report Affected Package The issue is caused by package @angular/service-worker Is this a regression? No Description We have an hybrid stack with old school PHP pages mixed with an Angular SPA...

X Description: 🐞 bug report Affected Package The issue is caused by package @angular/service-worker Is this a regression? No Description We have an hybrid stack with old school PHP pages mixed with an Angular SPA...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Angular Service Worker breaks HTML forms POST submit","articleBody":"\u003c!--🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅\r\n\r\nOh hi there! 😄\r\n\r\nTo expedite issue processing please search open and closed issues before submitting a new one.\r\nExisting issues often contain information about workarounds, resolution, or progress updates.\r\n\r\n🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅-->\r\n\r\n\r\n# 🐞 bug report\r\n\r\n### Affected Package\r\n\u003c!-- Can you pin-point one or more @angular/* packages as the source of the bug? -->\r\nThe issue is caused by package @angular/service-worker\r\n\r\n\r\n### Is this a regression?\r\n\r\n\u003c!-- Did this behavior use to work in the previous version? -->\r\nNo\r\n\r\n### Description\r\n\r\nWe have an hybrid stack with old school PHP pages mixed with an Angular SPA, and the Angular app has a wildcard route redirecting all non-SPA navigations to the legacy PHP stack.\r\n\r\nCombined with using the `ngsw-bypass` query param, the Angular Service Worker works great in most situations. However, it does break HTML forms `POST` submit, as the Service Worker would then return the app shell (even though `req.method` was `post`), causing the SPA to send a new `GET` request with the `ngsw-bypass` query param, and breaking the form submission.\r\n\r\nTo be clear, the entire reason why this is an issue for us is that we have way too many unknown PHP `POST` endpoints to be able to exclude them all from the `navigationUrls` regexes (and they often live next to actual SPA routes); the issue does not exist if the `POST` endpoint is excluded from `navigationUrls`.\r\n\r\nPatching `ngsw-worker.js` at build time solves our issue, however, considering that POST requests aren't supported by the Cache API / can't really be cached by Service Workers, that upload progress events are broken as well, and that (in our case) HTML form POST submits are broken when form action targets match `navigationUrls`, I wonder it there's a point for the Angular Service Worker to handle `POST` requests in the first place.\r\n\r\ni.e., is there any downside for the Angular Service Worker to not handle any `POST` requests at all like we've done?\r\n\r\n```\r\nif (req.method === 'POST' || req.headers.has('ngsw-bypass') || /[?&]ngsw-bypass(?:[=&]|$)/i.test(requestUrlObj.search)) {\r\n  return;\r\n}\r\n```\r\n\r\nLooking through the various GitHub issues for related bugs, I feel that this would make real-life Service Worker deployments much easier.\r\n\r\nAlternatively, I would argue that the Angular Service Worker should not return the app shell for `req.mode === 'navigation'` requests if `req.method` is not `GET`, in order to stay on the safe side.\r\n\r\n## 🔬 Minimal Reproduction\r\n\u003c!--\r\nPlease create and share minimal reproduction of the issue starting with this template: https://stackblitz.com/fork/angular-issue-repro2\r\n-->\r\nI've created a small repro at https://github.com/laurentgoudet/angular-service-worker-submit-post-bug: just `git checkout`, `yarn`, `node server.js`, and open `http://localhost:8080`: the form submit would be broken once the Service Worker has bootstrapped\r\n\r\n## 🌍  Your Environment\r\n\r\n**Angular Version:**\r\n\u003cpre>\u003ccode>\r\nlaurent@Laurents-MacBook-Pro webapp [laurent-sw-fix] $ ./node_modules/.bin/ng version\r\n\r\n     _                      _                 ____ _     ___\r\n    / \\   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|\r\n   / △ \\ | '_ \\ / _` | | | | |/ _` | '__|   | |   | |    | |\r\n  / ___ \\| | | | (_| | |_| | | (_| | |      | |___| |___ | |\r\n /_/   \\_\\_| |_|\\__, |\\__,_|_|\\__,_|_|       \\____|_____|___|\r\n                |___/\r\n\r\n\r\nAngular CLI: 9.0.5\r\nNode: 12.4.0\r\nOS: darwin x64\r\n\r\nAngular: 9.0.5\r\n... animations, cli, common, compiler, compiler-cli, core, forms\r\n... language-service, localize, platform-browser\r\n... platform-browser-dynamic, platform-server, router\r\n... service-worker\r\nIvy Workspace: Yes\r\n\r\nPackage                           Version\r\n-----------------------------------------------------------\r\n@angular-devkit/architect         0.900.3\r\n@angular-devkit/build-angular     0.900.3\r\n@angular-devkit/build-optimizer   0.900.3\r\n@angular-devkit/build-webpack     0.900.3\r\n@angular-devkit/core              9.0.3\r\n@angular-devkit/schematics        9.0.5\r\n@angular/cdk                      9.1.1\r\n@angular/material                 9.1.1\r\n@ngtools/webpack                  9.0.3\r\n@nguniversal/builders             9.0.1\r\n@nguniversal/common               9.0.2\r\n@nguniversal/express-engine       9.0.2\r\n@schematics/angular               9.0.5\r\n@schematics/update                0.900.5\r\nrxjs                              6.5.4\r\ntypescript                        3.7.5\r\nwebpack                           4.41.2\r\n\r\n\u003c/code>\u003c/pre>","author":{"url":"https://github.com/laurentgoudet","@type":"Person","name":"laurentgoudet"},"datePublished":"2020-04-01T12:46:27Z","url":"https://github.com/angular/angular/issues/36368"}

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:74f6395e-991f-411d-f2a7-d70bdf39ce54
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id9CB8:215B92:12436D1:1853C69:6B0121A0
html-safe-nonce26d80fffc5eeef61aba2b3826e0a73d92014f479fd7526de7b5dc07950d9f2bb
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5Q0I4OjIxNUI5MjoxMjQzNkQxOjE4NTNDNjk6NkIwMTIxQTAiLCJ2aXNpdG9yX2lkIjoiNTMyNTQ1NjgzNDAyOTQ5NDY4OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac354275942b2229237ef707750f5a6dab7344676881306c30b0c81184eddb3bba
hovercard-subject-tagissue:591888747
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/36368/issue_layout
twitter:imagehttps://opengraph.githubassets.com/5635eeac922541b8db2abad85eb53ad2121e9983a7993585342e6d1f383256fb/angular/angular/issues/36368
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/5635eeac922541b8db2abad85eb53ad2121e9983a7993585342e6d1f383256fb/angular/angular/issues/36368
og:image:alt🐞 bug report Affected Package The issue is caused by package @angular/service-worker Is this a regression? No Description We have an hybrid stack with old school PHP pages mixed with an Angular SPA...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamelaurentgoudet
hostnamegithub.com
expected-hostnamegithub.com
Nonecc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c
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
release8c77c9e8439031ad54c75a250694842892f693e1
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/angular/angular/issues/36368#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fangular%2Fangular%2Fissues%2F36368
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%2F36368
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/36368
Reloadhttps://github.com/angular/angular/issues/36368
Reloadhttps://github.com/angular/angular/issues/36368
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/36368
New issuehttps://github.com/login?return_to=https://github.com/angular/angular/issues/36368
Angular Service Worker breaks HTML forms POST submithttps://github.com/angular/angular/issues/36368#top
P4A relatively minor issue that is not relevant to core functionshttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22P4%22
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
effort1: hourshttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22effort1%3A%20hours%22
freq1: lowhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22freq1%3A%20low%22
open for contributionsAn issue that is suitable for a community contributor (based on its complexity/scope).https://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22open%20for%20contributions%22
state: confirmedhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22state%3A%20confirmed%22
type: bug/fixhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22type%3A%20bug%2Ffix%22
Backloghttps://github.com/angular/angular/milestone/82
https://github.com/laurentgoudet
laurentgoudethttps://github.com/laurentgoudet
on Apr 1, 2020https://github.com/angular/angular/issues/36368#issue-591888747
https://github.com/laurentgoudet/angular-service-worker-submit-post-bughttps://github.com/laurentgoudet/angular-service-worker-submit-post-bug
Nexthttps://github.com/angular/angular/issues/36368?timeline_page=1
pkozlowski-opensourcehttps://github.com/pkozlowski-opensource
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 Apr 1, 2020https://github.com/angular/angular/issues/36368#event-3187847165
ngbothttps://github.com/apps/ngbot
needsTriagehttps://github.com/angular/angular/milestone/83
on Apr 1, 2020https://github.com/angular/angular/issues/36368#event-3187847266
https://github.com/laurentgoudet
laurentgoudethttps://github.com/laurentgoudet
on Apr 1, 2020https://github.com/angular/angular/issues/36368#issuecomment-607245567
#21191https://github.com/angular/angular/issues/21191
https://github.com/laurentgoudet
laurentgoudethttps://github.com/laurentgoudet
on Apr 1, 2020https://github.com/angular/angular/issues/36368#issuecomment-607251708
#25865https://github.com/angular/angular/issues/25865
gkalpakhttps://github.com/gkalpak
effort1: hourshttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22effort1%3A%20hours%22
freq1: lowhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22freq1%3A%20low%22
severity2: inconvenienthttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22severity2%3A%20inconvenient%22
type: bug/fixhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22type%3A%20bug%2Ffix%22
on Apr 1, 2020https://github.com/angular/angular/issues/36368#event-3189310893
ngbothttps://github.com/apps/ngbot
needsTriagehttps://github.com/angular/angular/milestone/83
Backloghttps://github.com/angular/angular/milestone/82
on Apr 1, 2020https://github.com/angular/angular/issues/36368#event-3189310955
https://github.com/gkalpak
gkalpakhttps://github.com/gkalpak
on Apr 1, 2020https://github.com/angular/angular/issues/36368#issuecomment-607442065
@laurentgoudethttps://github.com/laurentgoudet
#25865https://github.com/angular/angular/issues/25865
invalidate cacheshttps://github.com/angular/angular/blob/ec8bae1b2772b68416e1469ff680caaf433aac28/packages/service-worker/worker/src/data.ts#L319-L332
herehttps://github.com/angular/angular/blob/ec8bae1b2772b68416e1469ff680caaf433aac28/packages/service-worker/worker/src/app-version.ts#L180
@laurentgoudethttps://github.com/laurentgoudet
gkalpakhttps://github.com/gkalpak
open for contributionsAn issue that is suitable for a community contributor (based on its complexity/scope).https://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22open%20for%20contributions%22
state: confirmedhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22state%3A%20confirmed%22
triage #1https://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22triage%20%231%22
on May 26, 2020https://github.com/angular/angular/issues/36368#event-3374855310
ajitsinghkalerhttps://github.com/ajitsinghkaler
on Jun 30, 2020https://github.com/angular/angular/issues/36368#event-3498263815
fix(service-worker): Service Worker breaks HTML forms POST submithttps://github.com/ajitsinghkaler/angular/commit/ed8ad902c35b7ff6d57f6fc270aa3ab831f8e499
https://docs.github.com/articles/closing-issues-via-commit-messages
ed8ad90https://github.com/ajitsinghkaler/angular/commit/ed8ad902c35b7ff6d57f6fc270aa3ab831f8e499
jelbournhttps://github.com/jelbourn
P4A relatively minor issue that is not relevant to core functionshttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22P4%22
severity2: inconvenienthttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22severity2%3A%20inconvenient%22
on Oct 1, 2020https://github.com/angular/angular/issues/36368#event-3830205932
gkalpakhttps://github.com/gkalpak
hotlist: community-helphttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22hotlist%3A%20community-help%22
hotlist: community-helphttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22hotlist%3A%20community-help%22
on Mar 12, 2021https://github.com/angular/angular/issues/36368#event-4451488248
AndrewKushnirhttps://github.com/AndrewKushnir
triage #1https://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22triage%20%231%22
on Mar 15, 2022https://github.com/angular/angular/issues/36368#event-6239500432
gkalpakhttps://github.com/gkalpak
on Aug 25, 2022https://github.com/angular/angular/issues/36368#event-7262403402
fix(service-worker): only consider GET requests as navigation requestshttps://github.com/gkalpak/angular/commit/ac023f77a3ac828dffe906804a732204e42c4087
https://docs.github.com/articles/closing-issues-via-commit-messages
ac023f7https://github.com/gkalpak/angular/commit/ac023f77a3ac828dffe906804a732204e42c4087
AndrewKushnirhttps://github.com/AndrewKushnir
completedhttps://github.com/angular/angular/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
a0c3326https://github.com/angular/angular/commit/a0c3326485548e8d9b193f5472a9b02a02d679a6
on Sep 6, 2022https://github.com/angular/angular/issues/36368#event-7332323853
AndrewKushnirhttps://github.com/AndrewKushnir
on Sep 6, 2022https://github.com/angular/angular/issues/36368#event-7332323959
fix(service-worker): only consider GET requests as navigation requests (https://github.com/angular/angular/commit/28d33505fd4be00eaf4bf417cd27e20733ddfb80
https://docs.github.com/articles/closing-issues-via-commit-messages
28d3350https://github.com/angular/angular/commit/28d33505fd4be00eaf4bf417cd27e20733ddfb80
https://github.com/apps/angular-automatic-lock-bot
angular-automatic-lock-bothttps://github.com/apps/angular-automatic-lock-bot
on Oct 7, 2022https://github.com/angular/angular/issues/36368#issuecomment-1271784462
automatic conversation locking policyhttps://github.com/angular/angular/blob/8f24bc9443b3872fe095d9f7f77b308a361a13b4/docs/GITHUB_PROCESS.md#conversation-locking
angular-automatic-lock-bothttps://github.com/apps/angular-automatic-lock-bot
on Oct 7, 2022https://github.com/angular/angular/issues/36368#event-7544874055
Sign up for freehttps://github.com/signup?return_to=https://github.com/angular/angular/issues/36368
Sign in to commenthttps://github.com/login?return_to=https://github.com/angular/angular/issues/36368
P4A relatively minor issue that is not relevant to core functionshttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22P4%22
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
effort1: hourshttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22effort1%3A%20hours%22
freq1: lowhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22freq1%3A%20low%22
open for contributionsAn issue that is suitable for a community contributor (based on its complexity/scope).https://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22open%20for%20contributions%22
state: confirmedhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22state%3A%20confirmed%22
type: bug/fixhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22type%3A%20bug%2Ffix%22
BacklogNo due datehttps://github.com/angular/angular/milestone/82
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.