Add permissive CORS-layer to the backend
This commit is contained in:
parent
71badc7a78
commit
560297ad88
17
back/Cargo.lock
generated
17
back/Cargo.lock
generated
|
@ -939,6 +939,7 @@ dependencies = [
|
|||
"serde",
|
||||
"sqlx",
|
||||
"tokio",
|
||||
"tower-http",
|
||||
"tracing-subscriber",
|
||||
]
|
||||
|
||||
|
@ -1575,6 +1576,22 @@ dependencies = [
|
|||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tower-http"
|
||||
version = "0.5.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e9cd434a998747dd2c4276bc96ee2e0c7a2eadf3cae88e52be55a05fa9053f5"
|
||||
dependencies = [
|
||||
"bitflags 2.6.0",
|
||||
"bytes",
|
||||
"http",
|
||||
"http-body",
|
||||
"http-body-util",
|
||||
"pin-project-lite",
|
||||
"tower-layer",
|
||||
"tower-service",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tower-layer"
|
||||
version = "0.3.2"
|
||||
|
|
|
@ -8,4 +8,5 @@ axum = "0.7.5"
|
|||
serde = "1.0.204"
|
||||
sqlx = { version = "0.7.4", features = ["runtime-tokio", "sqlite"] }
|
||||
tokio = { version = "1.38.1", features = ["rt-multi-thread", "macros", "net", "time", "sync"] }
|
||||
tower-http = { version = "0.5.2", features = ["cors"] }
|
||||
tracing-subscriber = "0.3.18"
|
||||
|
|
|
@ -3,6 +3,7 @@ use std::str::FromStr;
|
|||
use axum::{
|
||||
extract::State, http::StatusCode, routing::post, Json, Router
|
||||
};
|
||||
use tower_http::cors::CorsLayer;
|
||||
|
||||
use sqlx::{Row, sqlite::{SqliteConnectOptions, SqlitePoolOptions}, Pool, Sqlite};
|
||||
|
||||
|
@ -48,6 +49,7 @@ async fn main() {
|
|||
.route("/api/echo", post(echo))
|
||||
.route("/api/get_counter", post(get_counter))
|
||||
.route("/api/set_counter", post(set_counter))
|
||||
.layer(CorsLayer::permissive())
|
||||
.with_state(state);
|
||||
|
||||
axum::serve(listener, app)
|
||||
|
|
Loading…
Reference in New Issue
Block a user