Canisters serve web pages and files themselves: an HTTP gateway turns a browser's HTTPS request into a call to the canister and checks the canister's proof that the response is authentic.
The path of a request
- A canister that answers HTTP is reachable at
https://CANISTER_ID.icp.net. The HTTP gateways (boundary nodes) route the request to the subnet hosting the canister and pass its answer back. - That gateway verifies the response's certification before handing it to the browser. The
CANISTER_ID.raw.icp.netform skips the check.
Hosting a frontend
- Use the
@dfinity/static-siterecipe inicp.yaml, pointed at your build folder (for exampledir: dist).icp deploycreates the certified-assets canister and uploads the files. The older@dfinity/asset-canisterrecipe still works for existing projects. - Every file is certified and compressed automatically. Add a
_redirectsfile for single-page-app routing and a_headersfile for custom headers such as a Content-Security-Policy. - A canister can also implement
http_requestitself to serve dynamic responses, certifying them with a library such asic-http-certification.
Certified data
Update calls are agreed by consensus and signed by the subnet. A query is answered by one node, so for data a client acts on, the canister certifies it and the client checks the certificate against the network's root key.
Addresses on a cloud engine
- Canister address (
https://CANISTER_ID.icp.net): always there; it can't be renamed or removed. - A subdomain of your engine's domain: live instantly, with no DNS setup. An engine owner or admin adds it from the app's page.
- A domain you own: add the DNS records the console shows at your DNS provider, have your app list the domain in
/.well-known/ic-domains, then register it with the HTTP gateway. TLS certificates are issued and renewed for you. Turn off your DNS provider's own SSL offering (Cloudflare's Universal SSL, for example), which gets in the way. - Internet Identity gives every address its own accounts. If your app signs people in, pin its derivation origin to the canister address before adding domains.
- In frontend code, don't set the agent's
hostto your custom domain: leave it unset, or usehttps://icp-api.io.