-
Notifications
You must be signed in to change notification settings - Fork 50
404 on /serviceworker.js in deployed environment #63
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
Comments
@rossta can you provide any assistance here? |
@illinixc The compiled serviceworker asset does not appear to be on your server. If you expect the file to be there, then make sure you've added the serviceworker asset tot the sprocket precompile config as described here: https://github.com/rossta/serviceworker-rails#precompile-the-assets and that your deployment process (capistrano? heroku?) is working as expected. If you are explicitly not putting compiled assets on your server—say, you are pushing the assets to your CDN directly—you could patch the project to handle such a case or have nginx perform the proxy. |
@rossta thanks for looking into it. Just curious, what makes you come to that conclusion? i'm not very proficient in rails and particularly the asset pipeline. I do have serviceworker.js in the precompile config according to the readme. from above:
|
The Rails log 404ing on |
Have you found any solution to this or what to look at? I am encountering a similar problem with Webpacker. |
I think this it happens due to this line here:
manifest.json (I suppose this is used for the lookup) contains urls prefixed with the asset_host . The fileserver might not be able to find these locally.
|
I wrote my custom service worker based on your ideas. The above issue can be solved by replacing the line above with: path = URI(Webpacker.manifest.lookup(pack_file)).path I can create a PR, if you want me to. |
@nikriek I tried forking the gem with the changes you mentioned, but I'm still getting an error on Heroku production. Hey @rossta , how would we resolve this on production? |
similar to #35, after deployment, i get a 404 on the serviceworker.js route. I am already on
0.5.5
though.match "/serviceworker.js" in serviceworker.rb
config.assets.compile = false
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
(false)localhost development is also working fine. from #35 (and a couple others) i will post the output of the same commands and info you've asked about. The conversation sort of stopped there so i dont know what results you were looking for.
ngjnx logs just show a 404 to /serviceworker.js
rails logs show a 404 to a path that looks to be more like a physical path?:
RAILS_ENV=production rake middleware
includes ServiceWorker middlewareFrom #44, I could grab nginx config if requested. There is a location that matches with "assets" but since thats not in the path and it does seem to be hitting the rails logs, it doesn't feel necessary.
Let me know if there's anything more i can provide, and thanks for making this gem!
The text was updated successfully, but these errors were encountered: