Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Encode URL for cog_viewer and stac_viewer #961

Merged
merged 2 commits into from
Jul 31, 2024
Merged

fix: Encode URL for cog_viewer and stac_viewer #961

merged 2 commits into from
Jul 31, 2024

Conversation

guillemc23
Copy link
Contributor

What I am changing

  • 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 😄

@vincentsarago vincentsarago merged commit 536b6a4 into developmentseed:main Jul 31, 2024
10 checks passed
@guillemc23 guillemc23 deleted the patch-1 branch July 31, 2024 13:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants