Question

spaces 403 when accessing public file through subdomain

Posted August 17, 2019 487 views
DigitalOceanObject StorageCDNDigitalOcean Spaces

SDK: AWS S3 JS SDK

I’ve created a spaces and assigned a subdomain to it, so upload works fine file is uploaded and can be viewed if using the origin URL while the Edge and Subdomain throw a 403.

Here is the upload code


spaces.putObject({
                            Bucket: storage.bucket,
                            ACL: "public-read",
                            Body: file,
                            Key: key,
                            CacheControl: 'max-age=3'
                            ContentType: fileType
                          })

any configuration I might be missing?

Thank you!

edited by bobbyiliev
4 comments

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
1 answer

Same on my side. I’ve contacted support again to find a solution.
Not sure why this happens.

  • could you please post a response here if you manage to get anything valuable from support, thank you

    • Sure, will do.

      On my end, I tried to purge the cache but it had no effect 30 minutes later.
      So unless the process takes longer than that (which is no impossible), I guess there is some kind of bug somewhere.

      • I haven’t heard back from the support yet, however I solved my problem.

        My droplets were making calls using the http protocol to a subdomain pointing to the space.

        I’m using Cloudflare with strict SSL and origin certificate.

        Accessing some objects over HTTP triggers the following:

        URL transformed to HTTPS due to an HSTS policy
        

        For the same object, from other droplets, it works.

        To solve the issue I forced all HTTP to be redirected to HTTPS.

Submit an Answer