How to use the assets directory? #2060
-
Hello, I try to use a picture from the asset directory. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
This kind of depends on how your server is set up exactly. The cargo-leptos docs say:
This means that whatever is in the Then the server can be set up to server static files from that directory. For example, if I look at the Actix starter template, it serves this App::new()
.route("/api/{tail:.*}", leptos_actix::handle_server_fns())
// serve JS/WASM/CSS from `pkg`
.service(Files::new("/pkg", format!("{site_root}/pkg")))
// serve other assets from the `assets` directory
.service(Files::new("/assets", site_root)) https://github.com/leptos-rs/start/blob/main/src/main.rs#L20-L25 So I can access a static file |
Beta Was this translation helpful? Give feedback.
This kind of depends on how your server is set up exactly.
The cargo-leptos docs say:
This means that whatever is in the
assets
directory will be copied to thesite-root
-- in the default case,target/site
.Then the server can be set up to server static files from that directory. For example, if I look at the Actix starter template, it serves this
site-root
directory at/assets
: