Need help with actix middleware in v4

I'm new to actix. I want to use Cors to make request from localhost. I've tried:

    let cors = Cors::permissive();

    let app = App::new()

        .wrap(cors)
        .service(listSampleAnalyzeFiles)
        .service(upload)
        ;

    HttpServer::new(|| { app })
        .bind((SERVER_ADDR, SERVER_PORT))?
        .run()
        .await

But it won't compile. Error message is:

the trait bound `App<impl ServiceFactory<ServiceRequest, Response = ServiceResponse<EitherBody<BoxBody>>, Error = actix_web::Error, Config = (), InitError = ()>>: Clone` is not satisfied in `[closure@src\main.rs:21:21: 21:31]

wrap() returns App<impl ServiceFactory<..>> while App::new() returns App<AppEntry>. What am I doing wrong?

I'm using
actix-web = "4.1.0"
actix-cors = "0.6.1"

HttpServer::new(|| {
    let cors = Cors::permissive();

    App::new()
        .wrap(cors)
        .service(listSampleAnalyzeFiles)
        .service(upload)
})
.bind((SERVER_ADDR, SERVER_PORT))?
.run()
.await
1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.