leptos-rs / start-actix

Starter template for use with the Leptos web framework.
The Unlicense
120 stars 31 forks source link

Actix routes return 404? #51

Closed adundovi closed 2 weeks ago

adundovi commented 2 weeks ago

I cloned and complied this template with nightly and I receive HTTP/1.1 404 Not Found in the HTTP header (curl --head http://127.0.0.1:3000), although the client (wasm code) content is correctly served on this route. I believe that something is wrong in passing on the App's router information, i.e. <Route path="" view=HomePage/>, when these same routes are registered with Actix (let routes = generate_route_list(App);)... Otherwise, Actix should return 200 OK when one visits path="".

adundovi commented 2 weeks ago

Just to add that the start-axum template works fine in the same case.

gbj commented 2 weeks ago

I agree that curl --head http://127.0.0.1:3000 returns a 404 and that curl -v http://127.0.0.1:3000 returns a 200 and the HTML.

I'd also note that the following Actix Hello-world example has the same behavior, so I do not think that this has anything to do with Leptos:

use actix_web::{web, App, HttpResponse, HttpServer};

async fn index() -> HttpResponse {
    HttpResponse::Ok().body("Hello")
}

#[actix_web::main]
async fn main() -> std::io::Result<()> {
    HttpServer::new(|| {
        App::new()
            .route("/", web::get().to(index))
            .route("/user", web::post().to(index))
    })
    .bind(("127.0.0.1", 8080))?
    .run()
    .await
}
gbj commented 2 weeks ago

Oh, you know what? The reality for either of those is that neither of them is set up to respond to HEAD requests, I guess.

This is the first time anyone's pointed this out. If it's a real issue for you that it doesn't respond to HEAD, feel free to open an issue in the main Leptos repo as this is due to the Actix integration there, not this template here.