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

feat: superhot support for w3s.link read #165

Merged
merged 2 commits into from
Aug 8, 2022

Conversation

vasco-santos
Copy link
Contributor

This PR adds support for superhot reads in w3s.link - we still need to look into moving this API into a common context instead of tied with nftstorage.link (not included in current initiative scope)

w3s.link should be able to read from SuperHot perma-cache and also share same content in R2 regardless of domain used for perma-cache. It currently gets 400 error due to not being a valid domain to get. This PR changes that by allowing reads from either nftstorage.link or w3s.link (array in ENV variable).

Moreover, I took decision here to modify normalized URLs to just be w3s.link all the time (converted from nftstorage.link when those are provided). Main reason for this is our current direction of Web3.storage platform and nft.storage being part of the stack.

Copy link

@alanshaw alanshaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just a couple of minor nits

Comment on lines +33 to +34
!env.GATEWAY_DOMAINS.filter((gwDomain) => urlString.includes(gwDomain))
.length
Copy link

@alanshaw alanshaw Aug 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
!env.GATEWAY_DOMAINS.filter((gwDomain) => urlString.includes(gwDomain))
.length
!env.GATEWAY_DOMAINS.includes(new URL(urlString).hostname)

...for the reason that the user could put w3s.link in the pathname otherwise.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const a = new URL('http://bafkreidyeivj7adnnac6ljvzj2e3rd5xdw3revw4da7mx2ckrstapoupoq.ipfs.localhost:9081')
a.hostname
'bafkreidyeivj7adnnac6ljvzj2e3rd5xdw3revw4da7mx2ckrstapoupoq.ipfs.localhost'

URLs are tricky, we can't go the way suggested here

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just url.host and .endsWith instead? I think it's better to use the domain if we can!

packages/api/src/utils/url.js Outdated Show resolved Hide resolved
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Aug 5, 2022

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 22052e6
Status: ✅  Deploy successful!
Preview URL: https://56f2f768.nftstorage-link.pages.dev
Branch Preview URL: https://feat-super-hot-support-w3s-l.nftstorage-link.pages.dev

View logs

Co-authored-by: Alan Shaw <alan.shaw@protocol.ai>
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