简体   繁体   English

Angular + Express PWA 504 网关

[英]Angular + Express PWA 504 Gateway

I'm having trouble creating a PWA angular app with NodeJS + Express server.我无法使用 NodeJS + Express 服务器创建 PWA angular 应用程序。

  • I'm serving my angular build --prod on a static path in Express我在 Express 的 static 路径上为我的 angular build --prod 提供服务
  • I'm using routes in my Angular App我在我的 Angular 应用程序中使用路由
  • The client manages to load manifest.json , ngsw-worker.js , ngsw.json?ngsw-cache-bust=[RANDOM] and all the rest of the files客户端设法加载manifest.json , ngsw-worker.js , ngsw.json?ngsw-cache-bust=[RANDOM]和文件的所有 Z65E8800B5C6800AAD8FCZZF888B2A62
  • The client creates an SW and shows this gear icon on every request客户端创建一个 SW 并在每个请求上显示此齿轮图标
  • The DevTools Disable cache checkbox is disabled;) DevTools 禁用缓存复选框被禁用;)

Yet, when I check the Offline checkbox in DevTools and refresh the page I get 504 on the requested route, and then a few seconds later, a failed request from ngsw-worker.js然而,当我检查 DevTools 中的 Offline 复选框并刷新页面时,我在请求的路由上得到 504,然后几秒钟后,来自ngsw-worker.js的请求失败

It's progress in my PWA app as I don't receive the Dinosaur chrome page.这是我的 PWA 应用程序的进展,因为我没有收到 Dinosaur chrome 页面。

Thanks in advance!提前致谢!

edit: Finally solved my related problem.编辑:终于解决了我的相关问题。 My issue was that when I was running my ng build --prod .我的问题是当我运行我的ng build --prod I had added && node patch.js to fix an issue in the build file.我添加了&& node patch.js来修复构建文件中的问题。 Apparently this was messing up my service worker hash.显然,这搞砸了我的服务人员 hash。 Now that I removed it everything is working great.现在我删除了它,一切都很好。 Lesson being that you can't screw around with the build folder after it has been generated.教训是您不能在生成文件夹后随意使用它。

I have this exact same setup with the same problem that I have been fighting with for the past couple days.我有这个完全相同的设置,但我在过去几天一直在解决同样的问题。 The service worker is being created correctly and I can see all JS chunks being downloaded on first loading.服务工作者正在正确创建,我可以看到所有 JS 块在第一次加载时被下载。 However I get the same 504 error when trying to go to a page offline that I have not already loaded while online.但是,当我尝试将 go 连接到我在线时尚未加载的离线页面时,我得到了相同的 504 错误。

One thought I was trying to look into was the "Referer" not pointing to the ngsw-worker on the 504 request.我试图调查的一个想法是“Referer”没有在 504 请求中指向 ngsw-worker。 I'm not sure if that could be an issue specific to Express with Angular PWA.我不确定这是否是 Express with Angular PWA 特有的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM