Commit 5734c97
fix(hosting/photo-storage): restore asset-canister recipe and fix canister-ID discovery (#1464)
* fix(hosting/photo-storage): restore asset-canister recipe and fix canister-ID discovery
The example was broken twice over:
1. The switch to @dfinity/static-site (#1449) removed the legacy asset
canister API (list/store/create_batch/commit_batch) that AssetManager
from @icp-sdk/canisters/assets depends on — the app's entire purpose.
Revert to @dfinity/asset-canister@v2.2.1, the only canister supporting
programmatic uploads, with a comment explaining the exception (#1459).
2. The dfx-era canister-ID parsing broke on icp-cli's name-based frontend
URLs (frontend.local.localhost) — Principal.fromText received
"frontend.local" and threw at module load (white screen). Replace the
hostname regex, ic0.app heuristic, and fetchRootKey() with the ic_env
cookie pattern used by hello_world (safeGetCanisterEnv), which works on
both URL forms and on mainnet.
Also fix the README authorize command (canister is named frontend, not
photo-storage) and point deploy instructions at the URL icp deploy prints.
Verified end-to-end locally: gallery renders, uploads work after
authorize, photos persist across reloads.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* fix(hosting/photo-storage): address review — drop cookie-less fallback, fix README filename
The ?canisterId= query-param fallback ran without the ic_env cookie and
therefore without the local root key — a half-broken path nothing uses
(the app is only ever served from the canister, which always sets the
cookie; there is no dev-server flow). Require the cookie and fail with a
clear error instead. Deliberately no fetchRootKey(): that is legacy
behavior we no longer recommend — the root key comes from the certified
ic_env cookie.
Also fix the README warning to reference src/App.jsx (renamed from
App.js in the Vite migration).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>1 parent 3113452 commit 5734c97
3 files changed
Lines changed: 25 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
| 41 | + | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
| 44 | + | |
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
| 50 | + | |
51 | 51 | | |
52 | 52 | | |
53 | | - | |
| 53 | + | |
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
5 | 9 | | |
6 | 10 | | |
7 | 11 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
17 | 22 | | |
18 | 23 | | |
19 | | - | |
20 | | - | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
21 | 29 | | |
22 | 30 | | |
23 | 31 | | |
| |||
0 commit comments