-
Notifications
You must be signed in to change notification settings - Fork 167
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: nft.storage naive gateway implementation #908
Conversation
Deploying with
|
Latest commit: |
c673d98
|
Status: | ✅ Deploy successful! |
Preview URL: | https://50cc1366.nft-storage-1at.pages.dev |
1961d0b
to
30e7ad1
Compare
account_id = "fffa4b4363a7e5250af8357087263b3a" # Protocol Labs CF account | ||
zone_id = "fc6cb51dbc2d0b9a729eae6a302a49c9" # nft.storage zone | ||
route = "*gateway.nft.storage/*" | ||
vars = { IPFS_GATEWAY = "https://ipfs.io" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: We will need to setup multiple gateways, either we need to hardcode multiple here or we will need to use a string array and parse it. Leaving for when needed
002a852
to
e7f01c9
Compare
5787f43
to
19c5f81
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️ Awesome work so far!
packages/gateway/src/utils/cid.js
Outdated
export function getCidFromSubdomainUrl(url) { | ||
// Replace "ipfs-staging" by "ipfs" if needed | ||
const nUrl = url.replace('ipfs-staging', 'ipfs') | ||
const splitUrl = nUrl.split('.ipfs.') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At this point is splitUrl
not ['https://bafy...', 'nft.storage']
? splitUrl[0]
will fail to parse as a CID.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, the parameter name was unfortunate, it is the hostname:
getCidFromSubdomainUrl(url.hostname)
So, I guess just rename the parameter should be enough. Maybe better to send URL instead and get the hostname inside the function
"pretest": "npm run build ", | ||
"test": "npm-run-all -p -r mock:ipfs.io test:worker", | ||
"test:worker": "ava --verbose test/*.spec.js", | ||
"mock:ipfs.io": "smoke -p 9081 test/mocks/ipfs.io" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we spin up an IPFS node instead? We can use the IPFS HTTP API to add content that we want to fetch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's do this in the follow up PR (Race), I just commented to remember: #961 (review)
That's because I need to have tests where I can manipulate who is faster. In that PR it will be easier to do that, perhaps using a real ipfs node + smoke tests for other gateways
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes fine to do in follow up PR 😄
That's because I need to have tests where I can manipulate who is faster. In that PR it will be easier to do that, perhaps using a real ipfs node + smoke tests for other gateways
Maybe just a simple proxy server that adds a delay? I find smoke to have quite a big overhead in terms of knowing what to call the file, what the response object should look like, how to get requests parsed correctly etc.
3d046c4
to
5bd3fa9
Compare
Co-authored-by: Alan Shaw <[email protected]>
5bd3fa9
to
b13a6ae
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few minor tidyup things but this is good to go otherwise!
Co-authored-by: Alan Shaw <[email protected]>
2e0632f
to
c673d98
Compare
This PR adds a naive implementation of the gateway as a CF Worker using subdomains, where it simply forwards requests to the IPFS public gateway for now as part of #823
It includes:
ACM was configure in the TLS setup for the nft.storage domain, so that we can do:
bafkreidchi5c4c3kwr5rpkvvwnjz3lh44xi2y2lnbldehwmpplgynigidm.ipfs.nft.storage
bafkreidchi5c4c3kwr5rpkvvwnjz3lh44xi2y2lnbldehwmpplgynigidm.ipfs-staging.nft.storage
bafkreidchi5c4c3kwr5rpkvvwnjz3lh44xi2y2lnbldehwmpplgynigidm.ipfs-staging.nft.storage/path
Besides follow up work tracked on #823 needs:
Closes #867