fix: resolve ipfs:// URIs to HTTP gateway for NFT images and metadata…#853
fix: resolve ipfs:// URIs to HTTP gateway for NFT images and metadata…#853holps-7 wants to merge 9 commits intosolana-foundation:masterfrom
Conversation
|
@holps-7 is attempting to deploy a commit to the Solana Foundation Team on Vercel. A member of the Team first needs to authorize it. |
Greptile SummaryConverts
Confidence Score: 5/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[URI Input] --> B{Is Empty?}
B -->|Yes| C[Return Empty String]
B -->|No| D[Parse as URL]
D --> E{Is IPFS Protocol?}
E -->|Yes| F[Extract Path from Host + Pathname]
F --> G{Starts with 'ipfs/'?}
G -->|Yes| H[Remove 'ipfs/' Prefix]
G -->|No| I[Keep Path As-Is]
H --> J[Convert to HTTPS Gateway URL]
I --> J
J --> K{Is Proxy Enabled?}
E -->|No| K
K -->|No| L[Return URI]
K -->|Yes| M{Is HTTP/HTTPS?}
M -->|No| L
M -->|Yes| N[Return Proxied URI]
Last reviewed commit: 0249fd3 |
|
hey @Woody4618 can you review this PR? |
|
@holps-7 Could you, please, apply 'pnpm lint' and fix code style issues. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Please check the test suite. Several tests failed |
Replaced fake CID with real CIDv0 and CIDv1 values that pass the verifyCID validation introduced in the IPFS URI resolution changes. Added test coverage for malformed CID handling.
@rogaldh fixed this issue. the IPFS tests were using a fake CID that doesn't pass verifyCID. Updated to use a real CIDv0 and added a test for the malformed CID case. |
rogaldh
left a comment
There was a problem hiding this comment.
Hi. To merge this feature, we have to improve the metadata proxy endpoint. After completing this, this PR could be merged.
Thank you for contribution.
fyi @Woody4618
|
Hy @rogaldh what improvement are to be implemented for the proxy endpoint? if you can elaborate on this I can do it. |
Description
This PR resolves an issue where the Explorer fails to load NFT images and metadata that use the
ipfs://protocol scheme. Modern web browsers do not natively support theipfs://scheme, causing fetch and rendering failures for compressed and standard NFTs relying on it.This change intercepts
ipfs://URIs in the getProxiedUri utility and converts them to use a public HTTP gateway (https://ipfs.io/ipfs/) before any proxy logic is evaluated.Type of change
Screenshots
Before

After

Testing
ipfs://{hash}andipfs://ipfs/{hash}) under both proxy-enabled and proxy-disabled environments.pnpm testlocally to ensure all suites pass.pnpm dev) and checking an NFT with anipfs://image URI (7rAhawfSxmqxjmSayjkLD44GoJA772R2QXBg174bobFWon devnet) to confirm it visually renders without console errors.Related Issues
Fixes #807
Checklist
build:infoscript to update build informationAdditional Notes
We opted to fix this broadly at the getProxiedUri entry point rather than per-component, ensuring the HTTP gateway conversion cleanly applies to all metadata API fetchers and image rendering tools simultaneously.