'CORS Fairing: Turned missing route OPTIONS /api/v2/auth/register into an OPTIONS

Hello to the Stackoverflow Community, i got some Problems with my Page i can't use the Register there is a problem i don't know how i can get it to work.

"Error: Captcha validation failed, please try again."

and on the Server i get this Message

=> Error: No matching routes for OPTIONS /api/v2/auth/register.
=> Warning: Responding with 404 Not Found catcher.
=> CORS Fairing: Turned missing route OPTIONS /api/v2/auth/register into an OPTIONS pre- 
     flight request
=> Response succeeded.
    POST /api/v2/auth/register application/json:
=> Matched: POST /api/v2/auth/register application/json (register)
    sending request POST https://www.google.com/recaptcha/api/siteverify
=> Outcome: Success
=> Response succeeded.

i tried everything but nothing works, so maybe someone here in the Community can help me with the Problem.

#[post("/auth/register", format = "json", data = "<request_data>")]
pub fn register(conn: MainPGDatabase, request_data: Json<RegisterRequest>) -> JsonValue {
    if !verify_recaptcha(&request_data.captcha) {
        return json!({
          "success": false,
          "message": "Captcha validation failed, please try again."
        });
    };

    match account_services::register_user(
        &request_data.email,
        &request_data.username,
        &request_data.password,
        conn,
    ) {
        Ok(data) => {
            return json!({
              "success": true,
              "token": data
            });
        }
        Err(errmessage) => {
            return json!({
              "success": false,
              "message": errmessage
            });
        }
    }
}

fn verify_recaptcha(response: &String) -> bool {
    let data = ureq::post("https://www.google.com/recaptcha/api/siteverify").send_form(&[
        ("secret", &std::env::var("CAPTCHA_KEY").unwrap()),
        ("response", response),
    ]);

    let json = data.into_json().unwrap();

    let success: bool = json.get("success").unwrap().as_bool().unwrap();

    success
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source