#Static files not found

1 messages · Page 1 of 1 (latest)

mortal spruce
#

I have an application with the following folder structure:

.
├── Cargo.lock
├── Cargo.toml
├── htmltemps
│   ├── index.html
│   └── verification_email.html
├── migrations
│   ├── 20221227091940_users_table.down.sql
│   └── 20221227091940_users_table.up.sql
├── settings
│   ├── base.yaml
│   ├── local.yaml
│   └── production.yaml
├── src
│   ├── authentication
│   │   ├── mod.rs
│   │   └── security.rs
│   ├── lib.rs
│   ├── main.rs
│   ├── routes
│   │   ├── auth
│   │   │   ├── confirm_registration.rs
│   │   │   ├── ...
│   ├── settings.rs
│   ├── startup.rs
│   ├── telemetry.rs
│   ├── types
│   │   ├── email.rs
│   │   ├── ...
│   └── utils
│       ├── email.rs
│       ├── ...
├── static
│   └── style.css
└── tests
    └── api
        ├── health_check.rs
        ├── ...

I am using actix-files to serve static files inside startup.rs using:

async fn run(
    listener: std::net::TcpListener,
    db_pool: sqlx::postgres::PgPool,
) -> Result<actix_web::dev::Server, std::io::Error> {
    ...
    .service(
                actix_files::fs::Files::new("/static", ".")
                    .show_files_listing()
                    .use_last_modified(true),
            )
    ...
}

And rendering htmltemps/index.html with tera. In htmltemps/index.html, I tried to link static/style.css:

...
<link rel="stylesheet" href="/static/style.css" />
...

But it always says static/style.css not found even when I prepend it with / like /static/style.css. I will be glad if I can be helped.

bronze flicker
#

i think:

actix_files::fs::Files::new("/static", ",/static")
mortal spruce
#

Let me test it.