diff --git a/src/api.rs b/src/api.rs index f77ff56..8f9a3f4 100644 --- a/src/api.rs +++ b/src/api.rs @@ -16,6 +16,8 @@ async fn api_ticket(id: web::Path) -> impl Responder { //return struct values as string HttpResponse::Ok() .content_type(ContentType::plaintext()) + .insert_header(("Access-Control-Allow-Origin", "*")) + .insert_header(("content-type", "text/plain")) .body(format!( "Ticket ID: {}, Ticket Price: {}, Ticket Status: {}", fetched_ticket_data.id, fetched_ticket_data.category, fetched_ticket_data.description @@ -29,6 +31,8 @@ async fn api_admin(id: web::Path) -> impl Responder { //return struct values as string HttpResponse::Ok() .content_type(ContentType::plaintext()) + .insert_header(("Access-Control-Allow-Origin", "*")) + .insert_header(("content-type", "text/plain")) .body(format!( "Admin ID: {}, Admin Name: {}, Admin Email: {}", fetched_admin_data.id, fetched_admin_data.name, fetched_admin_data.address @@ -42,6 +46,7 @@ async fn api_driver(id: web::Path) -> impl Responder { .content_type(ContentType::plaintext()) //headers for plain text .insert_header(("Access-Control-Allow-Origin", "*")) + .insert_header(("content-type", "text/plain")) .body(format!( "Driver ID: {}, Driver Name: {}, Driver Email: {}", fetched_driver_data.id, fetched_driver_data.name, fetched_driver_data.address @@ -51,5 +56,7 @@ async fn api_driver(id: web::Path) -> impl Responder { async fn api_test() -> impl Responder { HttpResponse::Ok() .content_type(ContentType::plaintext()) + .insert_header(("Access-Control-Allow-Origin", "*")) + .insert_header(("content-type", "text/plain")) .body("My balls are on fire :(") }