chore: update feeds api auth
6d6f807b
4 file(s) · +11 −3
| 1417 | 1417 | "serde_json", |
|
| 1418 | 1418 | "subtle", |
|
| 1419 | 1419 | "tokio", |
|
| 1420 | + | "tower-http", |
|
| 1420 | 1421 | "tracing", |
|
| 1421 | 1422 | "tracing-subscriber", |
|
| 1422 | 1423 | "url", |
| 31 | 31 | url = "2" |
|
| 32 | 32 | mime_guess = "2" |
|
| 33 | 33 | urlencoding = "2" |
|
| 34 | + | tower-http = { version = "0.6.8", features = ["cors"] } |
| 79 | 79 | // ── Subscriptions ───────────────────────────────────────────────────── |
|
| 80 | 80 | ||
| 81 | 81 | pub async fn list_subscriptions( |
|
| 82 | - | _auth: ApiAuth, |
|
| 83 | 82 | State(state): State<Arc<AppState>>, |
|
| 84 | 83 | ) -> Response { |
|
| 85 | 84 | match fdb::list_subscriptions(&state.db) { |
| 15 | 15 | use askama::Template; |
|
| 16 | 16 | use axum::{ |
|
| 17 | 17 | extract::{Multipart, Path, Query, State}, |
|
| 18 | - | http::{header, HeaderMap, StatusCode}, |
|
| 18 | + | http::{header, HeaderMap, Method, StatusCode}, |
|
| 19 | 19 | response::{Html, IntoResponse, Json, Redirect, Response}, |
|
| 20 | 20 | routing::{delete, get, post}, |
|
| 21 | 21 | Form, Router, |
|
| 24 | 24 | use rust_embed::Embed; |
|
| 25 | 25 | use rusqlite::Connection; |
|
| 26 | 26 | use serde::Deserialize; |
|
| 27 | + | use tower_http::cors::{Any, CorsLayer}; |
|
| 27 | 28 | ||
| 28 | 29 | use crate::poller::POLL_INTERVAL_KEY; |
|
| 29 | 30 | ||
| 640 | 641 | "/api/settings", |
|
| 641 | 642 | get(api::get_settings).put(api::update_settings), |
|
| 642 | 643 | ) |
|
| 643 | - | .route("/api/discover", post(api::discover)); |
|
| 644 | + | .route("/api/discover", post(api::discover)) |
|
| 645 | + | .layer( |
|
| 646 | + | CorsLayer::new() |
|
| 647 | + | .allow_origin(Any) |
|
| 648 | + | .allow_methods([Method::GET]) |
|
| 649 | + | .allow_headers(Any), |
|
| 650 | + | ); |
|
| 644 | 651 | ||
| 645 | 652 | let app = Router::new() |
|
| 646 | 653 | .route("/", get(index_handler)) |
|