backend: fix default address for cookies
This commit is contained in:
parent
1447509699
commit
5b977aa042
@ -46,7 +46,7 @@ impl Config {
|
|||||||
name: env::var("DATABASE_NAME").unwrap_or("elnafo".to_string()),
|
name: env::var("DATABASE_NAME").unwrap_or("elnafo".to_string()),
|
||||||
},
|
},
|
||||||
server: Server {
|
server: Server {
|
||||||
address: env::var("SERVER_ADDRESS").unwrap_or("0.0.0.0".to_string()),
|
address: env::var("SERVER_ADDRESS").unwrap_or("127.0.0.1".to_string()),
|
||||||
port: env::var("SERVER_PORT")
|
port: env::var("SERVER_PORT")
|
||||||
.unwrap_or("54600".to_string())
|
.unwrap_or("54600".to_string())
|
||||||
.parse()
|
.parse()
|
||||||
|
21
src/main.rs
21
src/main.rs
@ -5,9 +5,9 @@ pub mod error_handle;
|
|||||||
pub mod state;
|
pub mod state;
|
||||||
|
|
||||||
use axum::{
|
use axum::{
|
||||||
extract::State,
|
extract::{Path, State},
|
||||||
http::{
|
http::{
|
||||||
header::{ACCEPT, AUTHORIZATION, CONTENT_TYPE, ORIGIN},
|
header::{ACCEPT, AUTHORIZATION, CONTENT_TYPE, COOKIE, ORIGIN},
|
||||||
HeaderValue, Method, StatusCode, Uri,
|
HeaderValue, Method, StatusCode, Uri,
|
||||||
},
|
},
|
||||||
middleware,
|
middleware,
|
||||||
@ -65,8 +65,11 @@ async fn main() {
|
|||||||
|
|
||||||
let cors = CorsLayer::new()
|
let cors = CorsLayer::new()
|
||||||
.allow_methods([Method::GET, Method::POST, Method::OPTIONS])
|
.allow_methods([Method::GET, Method::POST, Method::OPTIONS])
|
||||||
.allow_headers(vec![ORIGIN, AUTHORIZATION, ACCEPT, CONTENT_TYPE])
|
.allow_headers(vec![ORIGIN, AUTHORIZATION, ACCEPT, CONTENT_TYPE, COOKIE])
|
||||||
.allow_origin("http://0.0.0.0:54600".parse::<HeaderValue>().unwrap()) //Any)
|
.allow_origin([
|
||||||
|
"http://localhost:54600".parse().unwrap(),
|
||||||
|
"http://localhost:5173".parse().unwrap(),
|
||||||
|
]) //Any)
|
||||||
.allow_credentials(true); //"http://localhost:5173".parse::<HeaderValue>().unwrap());
|
.allow_credentials(true); //"http://localhost:5173".parse::<HeaderValue>().unwrap());
|
||||||
|
|
||||||
let app = Router::new()
|
let app = Router::new()
|
||||||
@ -75,10 +78,6 @@ async fn main() {
|
|||||||
.route("/assets/*file", get(static_handler))
|
.route("/assets/*file", get(static_handler))
|
||||||
.route("/api/v1/register_user", post(api::v1::register_user))
|
.route("/api/v1/register_user", post(api::v1::register_user))
|
||||||
.route("/api/v1/login_user", post(api::v1::login_user))
|
.route("/api/v1/login_user", post(api::v1::login_user))
|
||||||
.layer(cors)
|
|
||||||
.route("/api/v1/healthcheck", get(api::v1::healthcheck))
|
|
||||||
.route("/api/v1/users", get(users))
|
|
||||||
.route("/api/v1/logout_user", get(api::v1::logout_user))
|
|
||||||
.route(
|
.route(
|
||||||
"/api/v1/me",
|
"/api/v1/me",
|
||||||
get(api::v1::me).route_layer(middleware::from_fn_with_state(
|
get(api::v1::me).route_layer(middleware::from_fn_with_state(
|
||||||
@ -86,6 +85,10 @@ async fn main() {
|
|||||||
api::v1::jwt_auth,
|
api::v1::jwt_auth,
|
||||||
)),
|
)),
|
||||||
)
|
)
|
||||||
|
.layer(cors)
|
||||||
|
.route("/api/v1/healthcheck", get(api::v1::healthcheck))
|
||||||
|
.route("/api/v1/users", get(users))
|
||||||
|
.route("/api/v1/logout_user", get(api::v1::logout_user))
|
||||||
.layer(
|
.layer(
|
||||||
TraceLayer::new_for_http()
|
TraceLayer::new_for_http()
|
||||||
.make_span_with(trace::DefaultMakeSpan::new().level(Level::INFO))
|
.make_span_with(trace::DefaultMakeSpan::new().level(Level::INFO))
|
||||||
@ -109,6 +112,8 @@ async fn user_login() -> impl IntoResponse {
|
|||||||
frontend::BaseTemplate { view: "signin" }
|
frontend::BaseTemplate { view: "signin" }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn user(Path(user): Path<String>) -> impl IntoResponse {}
|
||||||
|
|
||||||
async fn users(
|
async fn users(
|
||||||
State(state): State<Arc<AppState>>,
|
State(state): State<Arc<AppState>>,
|
||||||
) -> Result<Json<Vec<User>>, (StatusCode, Json<serde_json::Value>)> {
|
) -> Result<Json<Vec<User>>, (StatusCode, Json<serde_json::Value>)> {
|
||||||
|
Loading…
Reference in New Issue
Block a user