Skip to content

Some hacks required to get it work with non-Rails #25

@katafrakt

Description

@katafrakt

Hey! I'm trying to use Snowpacker with Hanami and I finally managed to get it to work, but I needed to add two hacks to Snowpacker to achieve that. I wonder what would be your ideas for proper fixes.

Hack 1: 304 + Content-Type

When I reload the page and Snowpack server returns 304 (file not changed), Rack complains about it with an exception:

Rack::Lint::LintError: Content-Type header found in 304 response, not allowed
	/home/katafrakt/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rack-2.2.3/lib/rack/lint.rb:21:in `assert'
	/home/katafrakt/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rack-2.2.3/lib/rack/lint.rb:710:in `block in check_content_type'
	/home/katafrakt/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rack-2.2.3/lib/rack/lint.rb:706:in `each'
	/home/katafrakt/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rack-2.2.3/lib/rack/lint.rb:706:in `check_content_type'
	/home/katafrakt/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rack-2.2.3/lib/rack/lint.rb:70:in `_call'
	/home/katafrakt/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rack-2.2.3/lib/rack/lint.rb:38:in `call'
	/home/katafrakt/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rack-2.2.3/lib/rack/show_exceptions.rb:23:in `call'
	/home/katafrakt/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rack-2.2.3/lib/rack/handler/webrick.rb:95:in `service'
	/home/katafrakt/.rbenv/versions/2.6.6/lib/ruby/2.6.0/webrick/httpserver.rb:140:in `service'
	/home/katafrakt/.rbenv/versions/2.6.6/lib/ruby/2.6.0/webrick/httpserver.rb:96:in `run'
	/home/katafrakt/.rbenv/versions/2.6.6/lib/ruby/2.6.0/webrick/server.rb:307:in `block in start_thread'

I hacked it by modifying proxy.rb and adding this to the end of perform_request:

        re = super(env)
          if re[0] == 304
            re[1].delete('content-type')
          end
        re
      else

Hack 2: /web_modules

I'm trying to use Vue 3 with it. To achieve that I had to reroute /web_modules too in Rack proxy. This hack is in the beginning of perform_requests:

env["PATH_INFO"].gsub!(/^\/web_modules/, "/#{Snowpacker.config.output_path}/web_modules")

I know both of these are stupid, but with that it works, so they can be a starting point to find proper solutions.

Thanks for this project, by the way!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions