fix: drop hardcoded host from HttpAgent options in example frontends - #1488
Merged
Merged
Conversation
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
No unresolved issues were identified that would block approval.
Review effort: Lite
Findings: None
What changed in this PR
Removes hardcoded window.location.origin API hosts so SDK host resolution works on custom domains, with CSP updates for local/API endpoints.
Changes:
- Removes hardcoded hosts from Motoko and Rust frontend agents.
- Removes obsolete
hostwiring frommotoko/ic-pos. - Expands CSP
connect-srcfor qrcode and image-classification.
| File | Description |
|---|---|
| rust/who_am_i/src/frontend/src/actor.js | Updated as part of this pull request. |
| rust/vetkeys/password_manager/frontend/src/lib/encrypted_maps.ts | Updated as part of this pull request. |
| rust/vetkeys/password_manager_with_metadata/frontend/src/lib/password_manager.ts | Updated as part of this pull request. |
| rust/vetkeys/encrypted_notes_app_vetkd/frontend/src/lib/actor.ts | Updated as part of this pull request. |
| rust/vetkeys/basic_vetkd/frontend/src/main.js | Updated as part of this pull request. |
| rust/vetkeys/basic_timelock_ibe/frontend/src/main.ts | Updated as part of this pull request. |
| rust/vetkeys/basic_ibe/frontend/src/main.ts | Updated as part of this pull request. |
| rust/vetkeys/basic_bls_signing/frontend/src/main.ts | Updated as part of this pull request. |
| rust/qrcode/frontend/src/actor.js | Updated as part of this pull request. |
| rust/qrcode/frontend/public/_headers | Updated as part of this pull request. |
| rust/photo_gallery/frontend/src/actor.ts | Updated as part of this pull request. |
| rust/llm_chatbot/frontend/src/actor.js | Updated as part of this pull request. |
| rust/image-classification/frontend/src/actor.js | Updated as part of this pull request. |
| rust/image-classification/frontend/public/_headers | Updated as part of this pull request. |
| rust/hello_world/frontend/src/actor.js | Updated as part of this pull request. |
| rust/flying_ninja/frontend/src/actor.js | Updated as part of this pull request. |
| rust/face-recognition/frontend/src/actor.js | Updated as part of this pull request. |
| rust/evm_block_explorer/frontend/src/actor.js | Updated as part of this pull request. |
| rust/daily_planner/frontend/src/actor.js | Updated as part of this pull request. |
| motoko/who_am_i/src/frontend/src/actor.js | Updated as part of this pull request. |
| motoko/vetkeys/password_manager/frontend/src/lib/encrypted_maps.ts | Updated as part of this pull request. |
| motoko/vetkeys/password_manager_with_metadata/frontend/src/lib/password_manager.ts | Updated as part of this pull request. |
| motoko/vetkeys/encrypted_notes_app_vetkd/frontend/src/lib/actor.ts | Updated as part of this pull request. |
| motoko/vetkeys/basic_vetkd/frontend/src/main.js | Updated as part of this pull request. |
| motoko/vetkeys/basic_ibe/frontend/src/main.ts | Updated as part of this pull request. |
| motoko/vetkeys/basic_bls_signing/frontend/src/main.ts | Updated as part of this pull request. |
| motoko/superheroes/frontend/src/actor.js | Updated as part of this pull request. |
| motoko/random_maze/frontend/src/actor.js | Updated as part of this pull request. |
| motoko/llm_chatbot/frontend/src/actor.js | Updated as part of this pull request. |
| motoko/ic-pos/frontend/src/lib/env.ts | Updated as part of this pull request. |
| motoko/ic-pos/frontend/src/actors.tsx | Updated as part of this pull request. |
| motoko/hello_world/frontend/src/actor.js | Updated as part of this pull request. |
| motoko/flying_ninja/frontend/src/actor.js | Updated as part of this pull request. |
| motoko/filevault/frontend/src/actor.js | Updated as part of this pull request. |
| motoko/evm_block_explorer/frontend/src/actor.js | Updated as part of this pull request. |
| motoko/daily_planner/frontend/src/actor.js | Updated as part of this pull request. |
| motoko/cert-var/frontend/src/actor.js | Updated as part of this pull request. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
marc0olo
marked this pull request as ready for review
September 23, 2026 12:47
lwshang
approved these changes
Sep 23, 2026
@icp-sdk/core resolves the API host from the page: the page origin on localhost, ic0.app and icp0.io, and https://icp-api.io elsewhere. A hardcoded window.location.origin breaks frontends served from a custom domain, which does not serve /api. qrcode and image-classification extend connect-src, since calls now leave the page origin (localhost:8000 locally, icp-api.io on icp.net).
marc0olo
force-pushed
the
chore/drop-agent-host
branch
from
September 23, 2026 14:15
e0cddec to
cec8fc3
Compare
alin-at-dfinity
approved these changes
Sep 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Removes
host: window.location.originfrom theHttpAgent/createActoroptions in all example frontends (34 examples).@icp-sdk/corealready resolves the API host from the page: the page origin onlocalhost(incl. the Vite dev-server proxy),ic0.appandicp0.io, andhttps://icp-api.ioeverywhere else. A hardcoded origin breaks frontends served from a custom domain, which doesn't serve/api. The icp-cli skill dropped this pattern for the same reason (dfinity/icskills#303); the examples still carried it from before.Since calls no longer always go to the page origin (
localhost:8000locally,icp-api.ioonicp.net),rust/qrcodeandrust/image-classificationextend their CSPconnect-src. Without that, local calls are blocked (reproduced onqrcode). The other CSPs already allow both.Tested locally in a browser:
motoko/hello_worldandrust/qrcode. All touched frontends build. Mainnet not tested.The Internet Identity auth client got the same change in #1487 (merged); this PR is rebased on it.