Amazon S3 static website doesn't serve css or js files

18,563

Solution 1

The reason is, amazon S3 sets the content-type of css files to binary/octet-stream, follow this tutorial to solve this issue.

Solution 2

You need to select your css file and then from the Properties tab click on Metadata. This is to assign optional metadata to the object as a name-value pair. The Content-Type key must have the Value text/css

enter image description here

Share:
18,563

Related videos on Youtube

unnamedcrewman
Author by

unnamedcrewman

Updated on September 16, 2022

Comments

  • unnamedcrewman
    unnamedcrewman over 1 year

    I've been trying to set up a static website on Amazon S3. I've got things set up to use my personal domain, and so far I've been able to access the content just fine. All the links work, both for pages in the "root" directory and pages in subfolders, so it seems that S3 can follow the paths I'm using.

    The problem is that none of the CSS stylings is being applied to the pages (it works fine on the development server on my local machine). I've tried using relative and absolute paths, but this doesn't seem to be the problem. I can see the content just as it should be, and I can navigate the site normally, but there's just no styling.

    I've tried messing with permissions on the folders, but I'm clearly not getting something right. Am I missing something obvious? Surely S3 can use individual stylesheets?

    Thanks in advance for any thoughts.

  • unnamedcrewman
    unnamedcrewman about 11 years
    Wow, spot on. That was my problem, and the tutorial worked like a charm (I happen to own Transmit, so I'm all set). Thanks a lot.
  • user1158559
    user1158559 almost 9 years
    The link is dead, but essentially s3cmd put -m "text/css" $YOUR_PATH s3://$BUCKET/$YOUR PATH
  • naaman
    naaman about 6 years
    The following Gist helps out for a number of MIME types: github.com/swoodford/aws/blob/master/… (Linux/Mac)
  • Flávio Costa
    Flávio Costa almost 5 years
    guys, im getting the same problem. my JS works fine, but my CSS not ):
  • Rajat jain
    Rajat jain almost 5 years
    @user1158559 s3cmd put -m "text/css" ```$YOUR_PATH``` s3://$BUCKET/$YOUR PATH which path is this? $YOUR_PATH
  • user1158559
    user1158559 over 4 years
    You have to re-upload your CSS. $YOUR_PATH is the CSS file on your local machine.