You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fair warning, I am quite new at this Rust thing - so bear with me if I'm asking something quite obvious.
I'm trying to serve a ./www/dist folder that is generated by Astro. (static html that has a interactive island).
So currently, I get it to build, but It only points to the root index.html, I can not access any subroutes, even though they too are just static html files in a subfolder(/projects/index.html).
It also does not serve my api::openmeteo endpoint.
This is my current main.rs, that works in cargo run, but not build --release:
use actix_files as fs;use actix_web::{App,HttpServer};mod api;mod models;#[actix_web::main]asyncfnmain() -> std::io::Result<()>{
std::env::set_var("RUST_LOG","debug");
std::env::set_var("RUST_BACKTRACE","1");
env_logger::init();HttpServer::new(|| {App::new().service(api::openmeteo::openmeteo).service(
fs::Files::new("/","./www/dist").index_file("index.html").show_files_listing(),)}).bind(("127.0.0.1",8080))?
.run().await}
If I follow the guide in the readme I get something like this:
This only ends up serving the index on /, the api/opemeteo route does not exist and only GET/HEAD requests are allowed.
However it does end up building/bundling the _astro folder containing the built css, so at least the index looks pretty.
So, I'm probably just doing something very silly here, but I'd appreciate a little pointer in the right direction. (I tried searching, but couldnt quite find what I was looking for)
The text was updated successfully, but these errors were encountered:
You can reorder your routes, static files route usually is on the last place. There is now also other possibility, if you strongly need it on the first place (I do not think in your case it is the case tbh): see #54
For static resources I think only GET and HEAD requests are supported. It is fine, you cannot POST or PUT to static read only resource.
Hey there.
Fair warning, I am quite new at this Rust thing - so bear with me if I'm asking something quite obvious.
I'm trying to serve a ./www/dist folder that is generated by Astro. (static html that has a interactive island).
So currently, I get it to build, but It only points to the root index.html, I can not access any subroutes, even though they too are just static html files in a subfolder(/projects/index.html).
It also does not serve my api::openmeteo endpoint.
This is my current main.rs, that works in cargo run, but not build --release:
If I follow the guide in the readme I get something like this:
This only ends up serving the index on /, the api/opemeteo route does not exist and only GET/HEAD requests are allowed.
However it does end up building/bundling the _astro folder containing the built css, so at least the index looks pretty.
So, I'm probably just doing something very silly here, but I'd appreciate a little pointer in the right direction. (I tried searching, but couldnt quite find what I was looking for)
The text was updated successfully, but these errors were encountered: