Internet Computer

How does the Internet Computer serve my web app to browsers?

All help topics

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.net form skips the check.
Hosting a frontend
  • Use the @dfinity/static-site recipe in icp.yaml, pointed at your build folder (for example dir: dist). icp deploy creates the certified-assets canister and uploads the files. The older @dfinity/asset-canister recipe still works for existing projects.
  • Every file is certified and compressed automatically. Add a _redirects file for single-page-app routing and a _headers file for custom headers such as a Content-Security-Policy.
  • A canister can also implement http_request itself to serve dynamic responses, certifying them with a library such as ic-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 host to your custom domain: leave it unset, or use https://icp-api.io.
Learn more
Still stuck? Contact support