rubyonjets / jets

Ruby on Jets
http://rubyonjets.com
MIT License
2.6k stars 181 forks source link

deployed SVG assets not being marked with correct Content-Type in S3, not displaying in Chrome #563

Closed sam0x17 closed 3 years ago

sam0x17 commented 3 years ago

Checklist

My Environment

Software Version
Operating System MacOS 10.13
Jets 3.0.8
Ruby 2.7.2

Expected Behaviour

Deploying an SVG image in the public directory should result in a Content-Type of image/svg+xml, and the image should display correctly when embedded in an image tag regardless of browser.

Current Behavior

Deployed asset in S3 ends up with Content-Type: / a blank content type. This causes Chrome to be unable to display the image when embedded in an image tag. Firefox is unaffected. No error is displayed in the browser and the image can be loaded manually by visiting the image url, it just can't be embedded.

Step-by-step reproduction instructions

  1. Set up a blank jets project
  2. add an SVG file to the public directory
  3. embed the SVG file in an img tag on the welcome page
  4. deploy the project
  5. Image tag will work in Firefox but not in Chrome due to blank content-type

Solution Suggestion

At first I thought this was a CORS error, but upon overriding the Content-Type manually in S3, the issue was resolved. Would like to see jets do this automatically i.e. if the file extension is .svg, it should use Content-Type: image/svg+xml

tongueroo commented 3 years ago

Fixed in #564

sam0x17 commented 3 years ago

thanks so much!!! 💯