Skip to content

fix(icons): resolve icon paths relative to JSON config file - #123

Merged
Gaubee merged 1 commit into
mainfrom
fix/icon-relative-path
Dec 26, 2025
Merged

Gaubee merged 1 commit into
mainfrom
fix/icon-relative-path

Conversation

@Gaubee

@Gaubee Gaubee commented Dec 26, 2025

Copy link
Copy Markdown
Contributor

Problem

Icon paths like /icons/bfchainv2/tokens/bft.svg fail when deployed to subpaths (e.g., /KeyApp/webapp/).

Solution

Resolve icon paths relative to the JSON config file location instead of document.baseURI:

  • Add resolveRelativePath() and resolveIconPaths() in chain-config service
  • Paths are resolved when loading JSON, using the JSON file URL as base
  • Add isSameOrigin() in token-icon to distinguish local (.svg) vs CDN (icon-*.png) resources
  • Update default-chains.json to use relative paths (../icons/...)

Changes

  • src/services/chain-config/index.ts: Add path resolution logic
  • src/components/wallet/token-icon.tsx: Add same-origin detection
  • public/configs/default-chains.json: Use relative paths

Closes the 404 issue for token icons on GitHub Pages.

- Add resolveRelativePath() and resolveIconPaths() in chain-config service
- Resolve icon and tokenIconBase paths relative to JSON file URL when loading
- Add isSameOrigin() check in token-icon to distinguish local vs CDN resources
- Update default-chains.json to use relative paths (../icons/...)

This ensures icons work correctly regardless of deployment subpath.
@Gaubee
Gaubee merged commit a6c0245 into main Dec 26, 2025
5 checks passed
@Gaubee
Gaubee deleted the fix/icon-relative-path branch December 26, 2025 08:33
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.

1 participant