Skip to content

404 on /serviceworker.js in deployed environment #63

Open
@illinixc

Description

@illinixc

similar to #35, after deployment, i get a 404 on the serviceworker.js route. I am already on 0.5.5 though.

  • followed all instructions in README
  • https
  • CDN (i have also changed this to not use a Proc and just set to ENV['CDN_HOST'] directly to no effect)
    config.asset_host = Proc.new do |source|
      if source.starts_with?('/assets/') # per CloudFront path to origin mapping
        ENV['CDN_HOST']
      else
        nil # default behavior
      end
    end
  end
  • I have match "/serviceworker.js" in serviceworker.rb
  • config.assets.compile = false
  • config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? (false)
  • precompiling serviceworker.js, and verified presence of fingerprinted serviceworker.js file in public/assets/. https://<CDN_HOST>/assets/<fingerprinted_file> returns the correct javascript file. (note, needs the assets keyword in path)

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.

Rails.application.config.assets.compile         
=> false
 asset_path = ::ActionController::Base.helpers.asset_path('/serviceworker.js')
=> "/serviceworker.js"
code - 405
headers - {"Content-Type"=>"text/plain", "Content-Length"=>"19", "X-Cascade"=>"pass", "Allow"=>"GET, HEAD, OPTIONS"}
body - ["Method Not Allowed\n"]

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?:

"method": "GET",
    "path": "/srv/www/<removed>/current/public/assets/serviceworker-2ed7e64d46b390cd57183ad0bb4105a2a64f6a84923c2c0b47cab0f6f9747b0c.js",
    "format": "js",
    "controller": "ErrorsController",
    "action": "routing_error",
    "status": 404,

RAILS_ENV=production rake middleware includes ServiceWorker middleware

From #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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions