fix getting token through header cookies and not body

This commit is contained in:
2025-12-04 12:31:31 +01:00
parent 02c11137ff
commit 668173c40d
10 changed files with 58 additions and 63 deletions

View File

@@ -2,6 +2,8 @@ use axum::serve;
use axum::Extension;
use axum::extract::{ws::{Message, WebSocket, WebSocketUpgrade}, State};
use jsonwebtoken::{DecodingKey, EncodingKey};
use reqwest::header::AUTHORIZATION;
use reqwest::header::CONTENT_TYPE;
use tokio::net::TcpListener;
use tokio::sync::mpsc;
@@ -24,6 +26,8 @@ use crate::utils::auth::JwtKeys;
use std::env;
use dotenvy::dotenv;
use tower_http::cors::{CorsLayer, Any};
use axum::http::{Method, HeaderValue};
pub async fn notify_discord(msg: &str) -> Result<(), reqwest::Error> {
let payload = serde_json::json!({
@@ -88,10 +92,16 @@ std::panic::set_hook(Box::new(|info| {
};
let cors = CorsLayer::new()
.allow_origin("http://localhost:5173".parse::<HeaderValue>().unwrap())
.allow_credentials(true)
.allow_methods([Method::GET, Method::POST, Method::PUT , Method::OPTIONS])
.allow_headers([CONTENT_TYPE, AUTHORIZATION]);
let app = create_router(state)
.layer(Extension(jwt_keys));
.layer(Extension(jwt_keys))
.layer(cors);
let listener = TcpListener::bind("0.0.0.0:7080").await?;
serve(listener, app).into_future().await?;
Ok(())