Skip to content

3.16: Does recover not receive CORS error messages? #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
AshinZhou opened this issue Apr 11, 2025 · 1 comment
Open

3.16: Does recover not receive CORS error messages? #13

AshinZhou opened this issue Apr 11, 2025 · 1 comment

Comments

@AshinZhou
Copy link

AshinZhou commented Apr 11, 2025

In the code listing, the CORS errors printed in section 3.16 are not the same as those printed in section 3.17.
I checked the GitHub documentation of warp and found that there are relevant issues.

@AshinZhou
Copy link
Author

`#[tokio::main]
async fn main() {
let cors = warp::cors()
.allow_any_origin()
.allow_header("content-type")
.allow_methods(&[Method::PUT, Method::DELETE, Method::GET, Method::POST]);

let get_items = warp::get()
    .and(warp::path("questions"))
    .and(warp::path::end())
    .and_then(get_questions)

// this
.recover(return_error);

let routes = get_items.with(cors);

warp::serve(routes)
    .run(([127, 0, 0, 1], 3030))
    .await;

}`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant