How to use the assets files, like images in deveploment network
you need to define the “assets” canister in dfx.json file. For example :
“icevent_assets”: {
“dependencies”: [
“icevent”
],
“frontend”: {
“entrypoint”: “src/icevent_assets/src/index.html”
},
“source”: [
“src/icevent_assets/assets”,
“dist/icevent_assets/”
],
“type”: “assets”
}
in the source folder, you can put any assets as normal webapps
Thanks for answer, but i don’t know was how to use the images in assets canister.
In IC network, set the img src to " https://<CANISTER_ID>.raw.ic0.app/1.png",
What i should do in Local network
You need to install icx-proxy
from the agent-rs
repo.
Then, run something like this:
icx-proxy --address 192.168.1.67:8000 --replica http://localhost:$(cat ~/<your home dir>/.dfx/replica-configuration/replica-1.port) --dns-alias 192.168.1.67:rkp4c-7iaaa-aaaaa-aaaca-cai -v -v
Make sure you run dfx replica
as well.
Then, replace the IP address, canister ID, and with your own, and call https://192.168.1.67:8000/<asset name>
.
Thanks, i will give it a try
Hello, I’m having trouble installing the tool on a Mac (Monterey). Are there any things I need to consider?
Which tool are you referring to?
ich-proxy, I have tried to install it on my mac, but without success, a lot of missing dependencies,
I have tried it also on a fresh ubuntu 20 box, but unfortunately there is a bug.
You can find here the issue: https://github.com/dfinity/icx-proxy/issues/8
I use an M1 Mac and haven’t had any issues, although I use nix.
If you’re interested I could share the nix flake I used.
Thank you, I use homebrew and will not change my settings. That will bring more problems, eventually.
The reason for that tool is, I try to setup a local replica which all developers in my company can use as a kind of central development server.
Do you have any solution for that ?
Thanks for any hint.
The great thing about nix flakes is that they are project-local but share a global cache (the nix store)
Anyway, I’ll take a look and see what I had to do to get it working.
Do you have any specific errors you’re running into?
You don’t actually need to run the proxy yourself - dfx deploy will work, and you can access the files on your local network using localhost:8000
.
On Chromium, it’s possible to use the url pattern of http://<canister-id>.localhost:8000/<asset>
, while for most browsers, you will need to use http://localhost:8000/<asset>?canisterId=<canister-id>
ok, but the question for me is, can I access the frontend canister also from other machines in my network?
I built from source and had to make sure some dependencies were available. Here’s what I did, in case it helps:
buildInputs = [] ++ pkgs.lib.optionals pkgs.stdenv.isDarwin [
pkgs.darwin.apple_sdk.frameworks.Security
pkgs.libiconv
# https://nixos.wiki/wiki/Rust#Building_the_openssl-sys_crate
pkgs.openssl_1_1
pkgs.pkgconfig
];
thank you for your answer, but I solved my problem by changing the dfx.json network binding from 127.0.0.1 to my local IP 192.x.x.x and this is working too.
I personally usually reach for ngrok
first in those situations, but that’s a good tip!