From 71da521a5368ba6f8d8dc2dbbec2b74b394faf8e Mon Sep 17 00:00:00 2001 From: phoenix Date: Tue, 30 Jun 2026 11:55:32 -0400 Subject: [PATCH] CORS bug fix (#28) Reviewed-on: http://git.kundeng.us/phoenix/textsender_api/pulls/28 --- .gitea/workflows/pr.yml | 4 ++++ Cargo.lock | 5 +---- Cargo.toml | 9 +++------ src/config/mod.rs | 1 + tests/test.rs | 2 +- 5 files changed, 10 insertions(+), 11 deletions(-) diff --git a/.gitea/workflows/pr.yml b/.gitea/workflows/pr.yml index 81f9e2c..40dfaac 100644 --- a/.gitea/workflows/pr.yml +++ b/.gitea/workflows/pr.yml @@ -5,6 +5,10 @@ on: branches: - main +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: check: name: Check diff --git a/Cargo.lock b/Cargo.lock index 0fe8c99..e7cea91 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3129,22 +3129,19 @@ dependencies = [ [[package]] name = "textsender_api" -version = "0.2.0" +version = "0.2.1" dependencies = [ "axum", "axum-extra", - "futures", "josekit", "jsonwebtoken", "serde", "serde_json", "sqlx 0.9.0", "swoosh", - "tempfile", "textsender_models", "time", "tokio", - "tokio-util", "tower", "tower-http", "tracing-subscriber", diff --git a/Cargo.toml b/Cargo.toml index 4d2860e..07cc86a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "textsender_api" -version = "0.2.0" +version = "0.2.1" edition = "2024" rust-version = "1.96" @@ -10,21 +10,18 @@ axum-extra = { version = "0.12.6", features = ["cookie"] } serde = { version = "1.0.228", features = ["derive"] } serde_json = { version = "1.0.150" } tokio = { version = "1.52.3", features = ["full"] } -tokio-util = { version = "0.7.18", features = ["io"] } -tower = { version = "0.5.3", features = ["full"] } tower-http = { version = "0.6.11", features = ["cors", "timeout"] } tracing-subscriber = "0.3.23" -futures = { version = "0.3.32" } uuid = { version = "1.23.3", features = ["v4", "serde"] } sqlx = { version = "0.9.0", features = ["runtime-tokio", "tls-native-tls", "postgres", "time", "uuid"] } time = { version = "0.3.49", features = ["formatting", "macros", "parsing", "serde"] } jsonwebtoken = { version = "10.4.0", features = ["rust_crypto"] } -josekit = { version = "0.10.3" } utoipa = { version = "5.5.0", features = ["axum_extras"] } utoipa-swagger-ui = { version = "9.0.2", features = ["axum"] } textsender_models = { git = "ssh://git@git.kundeng.us/phoenix/textsender_models.git", tag = "v0.4.10" } swoosh = { git = "ssh://git@git.kundeng.us/phoenix/swoosh.git", tag = "v0.4.2.0" } [dev-dependencies] +tower = { version = "0.5.3", features = ["full"] } +josekit = { version = "0.10.3" } url = { version = "2.5.8" } -tempfile = { version = "3.27.0" } diff --git a/src/config/mod.rs b/src/config/mod.rs index a52ebb8..64f871e 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -33,6 +33,7 @@ pub mod init { let cors = tower_http::cors::CorsLayer::new() .allow_methods([ axum::http::Method::GET, + axum::http::Method::PATCH, axum::http::Method::POST, axum::http::Method::PUT, axum::http::Method::DELETE, diff --git a/tests/test.rs b/tests/test.rs index 09c8172..69289d1 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -204,7 +204,7 @@ pub async fn test_token() -> Result { }; match textsender_models::token::create_token(&key, &token_resource, time::Duration::hours(1)) { - Ok((access_token, _some_time)) => Ok(access_token), + Ok(access_token) => Ok(access_token.access_token), Err(err) => Err(err), } }