用途:把已构建的前端、文档或任意静态文件目录部署到 Internet Computer 的 certified-assets canister,由该 canister 通过 HTTP 提供经过响应认证的内容;这是官方推荐的 IC 前端托管方式,取代旧的 @dfinity/asset-canister。
主要能力:通过 icp.yaml 声明 recipe,指向构建目录即可完成上传、认证与托管;支持 SPA 路由重写、自定义重定向、自定义响应头、干净 URL、自定义 404 页面与自定义域名。canister 只使用 certification v2,每个响应都由认证网关校验,访问 https://<canister-id>.icp.net 会验证,而 https://<canister-id>.raw.icp.net 不验证。
用法:需要 icp-cli(npm install -g @icp-sdk/icp-cli)和 ic-wasm(npm install -g @icp-sdk/ic-wasm,仅在设置 metadata 时被调用),以及前端自身的构建工具链。在 icp.yaml 中使用 recipe: type: "@dfinity/static-site@v0.4.0",配置字段为 dir(必填)、build、presync、metadata。部署后 canister ID 保存在 .icp/<cache|data>/mappings/<environment>.ids.json。可通过 dir 根部放置 _redirects 与 _headers 配置 SPA 回退(/* /index.html 200)、重定向、缓存与安全头。
限制与注意事项:不读取 .ic-assets.json5,也不支持 AssetManager / @icp-sdk/canisters 的上传 API;_headers 拒绝 Content-Length、Content-Encoding、ETag、Transfer-Encoding、Accept-Ranges、Content-Range、IC-Certificate、IC-CertificateExpression、Location 等保留头;4xx 错误页目标必须为小于约 1.9 MB 的单块小文件;不支持 :splat 或 :placeholder 动态捕获;默认不添加安全头;从旧 asset canister 迁移或跨破坏性版本升级需用 icp deploy --mode reinstall(会清空状态)。