tigris presigned urls give access denied (using ExAws) - Tigris
tigris presigned urls give access denied (using ExAws)
When I try to upload a presigned URL using ExAws, I get a URL like:
https://(url)?...
The image uploads correctly to the bucket, but when I later try to display it on my page I receive an AccessDenied error.
The problem is that the generated URL places the bucket name after the domain instead of as a sub‑domain.
I can fix this by adding the parameter virtual_host: true to the presigned_url call, which makes the bucket name appear in the sub‑domain, allowing the file to be accessed via the URL. However, using this option causes an error during the upload process:
create:1 Access to XMLHttpRequest at '(url)' from origin 'https://(url)' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
app-368ae2410464362c35571e4889b79eb8.js?vsn=d:721 PUT https://[PRESIGNED_URL] net::ERR_FAILED
(anonymous) @ app-368ae2410464362c35571e4889b79eb8.js?vsn=d:721
S3 @ app-368ae2410464362c35571e4889b79eb8.js?vsn=d:721
initAdapterUpload @ app-368ae2410464362c35571e4889b79eb8.js?vsn=d:714
...
Any ideas on how to make this work?
Hi
Can you show the full URL with signature hidden?
Sure thing:
Here is the ExAws config used to generate the presigned URL:
config = %{
port: 443,
scheme: "https://",
host: "fly.storage.tigris.dev",
http_client: ExAws.Request.Hackney,
access_key_id: "...",
secret_access_key: "...",
region: "auto",
retries: [max_attempts: 10, base_backoff_in_ms: 10, max_backoff_in_ms: 10000],
json_codec: Jason,
normalize_path: true,
require_imds_v2: false
}
And here is the full generated URL:
https://fly.storage.tigris.dev/placeholder-bucket/temp/[OBJECT_KEY]?[PRESIGNED_PARAMS]
This will upload correctly, but then the output URL from the uploader will not be accessible:
https://fly.storage.tigris.dev/placeholder-bucket/temp/[OBJECT_KEY]?[PRESIGNED_PARAMS]/temp/[OBJECT_KEY]
I can only access that URL if I move the bucket to be a subdomain manually:
https://placeholder-bucket.fly.storage.tigris.dev/temp/[OBJECT_KEY]?[PRESIGNED_PARAMS]/temp/[OBJECT_KEY]
Ok, I found a solution for it.
Seems like the fly.storage.tigris.dev URL is broken, but the t3.storage.dev works fine.
So, I just replaced the Fly URL with the T3 one and now it works great.