v0.10-frontend-compiles2

This commit is contained in:
2022-10-31 00:24:15 +05:30
parent fe40782c0e
commit bc58e586f7
3 changed files with 45 additions and 39 deletions

View File

@@ -12,7 +12,7 @@ use std::collections::HashMap;
use std::net::{IpAddr, Ipv6Addr, SocketAddr};
use std::str::FromStr;
use tower::ServiceBuilder;
use tower_http::cors::CorsLayer;
use tower_http::cors::{Any,CorsLayer};
use tower_http::trace::TraceLayer;
use booksman_orm::{
sea_orm::{Database, DatabaseConnection},
@@ -144,8 +144,9 @@ pub async fn main() {
// it is required to add ".allow_headers([http::header::CONTENT_TYPE])"
// or see this issue https://github.com/tokio-rs/axum/issues/849
CorsLayer::new()
.allow_origin("http://localhost:8080".parse::<HeaderValue>().unwrap())
.allow_methods([Method::GET, Method::POST]),
.allow_methods([Method::GET, Method::POST])
.allow_origin("http://localhost:8080".parse::<HeaderValue>().unwrap())
.allow_headers(Any),
);
let sock_addr = SocketAddr::from((
@@ -283,6 +284,7 @@ async fn create_book(
Extension(ref conn): Extension<DatabaseConnection>,
doc_sent : Form<BookUI>,
) -> impl IntoResponse {
println!("Creating book");
let book: book::Model = book::Model{
open_library_key: doc_sent.open_library_key.to_owned(),
title: (doc_sent.title.to_owned()),