flightlesstux / S3-Directory-Listing

Are you tired of the boring, generic S3 bucket listings? 🥱 Well, look no further! 😎
25 stars 8 forks source link

Error fetching objects: Failed to fetch after following ReadMe #15

Closed mblanche closed 1 year ago

mblanche commented 1 year ago

Hi, this seems exactly what I am looking for. However, following the readme, I get a "Error fetching objects: Failed to fetch" error.

I have

  1. static web hosting turned on in the bucket properties

  2. In bucket permision, all of the "block public access" items are turned off

  3. In permission, bucket policy is set to

    {
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "S3DirectoryListing",
            "Effect": "Allow",
            "Principal": "*",
            "Action": [
                "s3:GetObject",
                "s3:ListBucket"
            ],
            "Resource": [
                "arn:aws:s3:::test.eclipseb.io/*",
                "arn:aws:s3:::test.eclipseb.io"
            ]
        }
    ]
    }
  4. In CORS, the following settings are in:

    [
    {
        "AllowedHeaders": [
            "*"
        ],
        "AllowedMethods": [
            "GET"
        ],
        "AllowedOrigins": [
            "*"
        ],
        "ExposeHeaders": []
    }
    ]
  5. I confirmed that I can view a basic index.html from the S3 static webhost http://test.eclipseb.io.s3-website-us-west-2.amazonaws.com/

  6. I cloned the repos and updated the s3.js file with const bucketName = 'test.eclipseb.io'

  7. Uploaded index.html, s3.js and dark-mode.css to the root of s3://test.eclipseb.io bucket

  8. Pointing my browser back to http://test.eclipseb.io.s3-website-us-west-2.amazonaws.com/ give me the following error:

    Screenshot 2023-09-27 at 9 07 00 AM

What am I missing?

Thanks

mblanche commented 1 year ago

Ah!! Looking at your code (although my .js is very weak...), I now see a possible issue. You are calling a secure host via https://, my current setup is http only. Looking at the endpoint, this http://test.eclipseb.io.s3.amazonaws.com/?list-type=2& returns and xml while https://test.eclipseb.io.s3.amazonaws.com/?list-type=2& returns an error.

However, updating the .js to http does not solve the problem. As I said, .js and web design is not what I do so I'm not sure what the real issue is.

Thanks

flightlesstux commented 1 year ago

Hi @mblanche,

As I see now, you fixed all of your problems, and http://test.eclipseb.io.s3-website-us-west-2.amazonaws.com/ is working normally. If you don't have any problem fetching objects, feel free to close this issue.

Best, Ercan