add user conv impl
This commit is contained in:
19
src/main.rs
19
src/main.rs
@@ -1,6 +1,7 @@
|
||||
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;
|
||||
@@ -25,8 +26,8 @@ use crate::utils::auth::JwtKeys;
|
||||
|
||||
use std::env;
|
||||
use dotenvy::dotenv;
|
||||
|
||||
use tower_http::cors::{CorsLayer, Any};
|
||||
//use tower_http::cors::Origin;
|
||||
use tower_http::cors::{CorsLayer, Any,};
|
||||
use axum::http::{Method, HeaderValue};
|
||||
|
||||
pub async fn notify_discord(msg: &str) -> Result<(), reqwest::Error> {
|
||||
@@ -91,13 +92,15 @@ std::panic::set_hook(Box::new(|info| {
|
||||
decoding: DecodingKey::from_secret(jwt_secret.as_ref()),
|
||||
};
|
||||
|
||||
let allowed_origins = vec![
|
||||
"http://82.66.253.209",
|
||||
"http://localhost:5173",
|
||||
];
|
||||
|
||||
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 cors = CorsLayer::very_permissive()
|
||||
.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(cors);
|
||||
|
||||
Reference in New Issue
Block a user