I am testing my own TiTiler instance reading some COGs stored at my own S3 storage. I realized that when passing the signed URL for the resource to the /viewer endpoint, it won't work as the first query to /info doesn't go through. I tried encoding my urls with an online tool (https://www.urlencoder.org/) and it works perfectly fine. Calling the /info endpoint from the docs works as expected with the URL as-is, so I took a look at the Viewer template.
When testing these urls using the docs, the curl command I get as result looks to have the URL properly encoded.
How I did it
In the Viewer template, I added the encodeURIComponent function to the introduced URL that does the same thing as the URL encoder referenced above. The change is minimal.
I changed as well the template for the STAC viewer as I noticed the code for both is very similar.
How you can test it
Just changing the template should have a minimal impact, but, adding to the viewer a signed url to a S3 resource should work now. My S3 urls look like: http://s3.mydomain.com/user-data/cog/MAD.tiff?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=XXXXXXX&X-Amz-Date=20240731T071151Z&X-Amz-Expires=1800&X-Amz-SignedHeaders=host&X-Amz-Signature=XXXXXXXXXX
I believe this should be the case with any other URL that contains special characters or multiple parameters.
Related Issues
None yet, I was faster with the PR than opening a new issue 😄
What I am changing
/viewer
endpoint, it won't work as the first query to/info
doesn't go through. I tried encoding my urls with an online tool (https://www.urlencoder.org/) and it works perfectly fine. Calling the/info
endpoint from the docs works as expected with the URL as-is, so I took a look at the Viewer template.How I did it
encodeURIComponent
function to the introduced URL that does the same thing as the URL encoder referenced above. The change is minimal.How you can test it
http://s3.mydomain.com/user-data/cog/MAD.tiff?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=XXXXXXX&X-Amz-Date=20240731T071151Z&X-Amz-Expires=1800&X-Amz-SignedHeaders=host&X-Amz-Signature=XXXXXXXXXX
Related Issues