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()),
|
||||
},
|
||||
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")
|
||||
.unwrap_or("54600".to_string())
|
||||
.parse()
|
||||
|
21
src/main.rs
21
src/main.rs
@ -5,9 +5,9 @@ pub mod error_handle;
|
||||
pub mod state;
|
||||
|
||||
use axum::{
|
||||
extract::State,
|
||||
extract::{Path, State},
|
||||
http::{
|
||||
header::{ACCEPT, AUTHORIZATION, CONTENT_TYPE, ORIGIN},
|
||||
header::{ACCEPT, AUTHORIZATION, CONTENT_TYPE, COOKIE, ORIGIN},
|
||||
HeaderValue, Method, StatusCode, Uri,
|
||||
},
|
||||
middleware,
|
||||
@ -65,8 +65,11 @@ async fn main() {
|
||||
|
||||
let cors = CorsLayer::new()
|
||||
.allow_methods([Method::GET, Method::POST, Method::OPTIONS])
|
||||
.allow_headers(vec![ORIGIN, AUTHORIZATION, ACCEPT, CONTENT_TYPE])
|
||||
.allow_origin("http://0.0.0.0:54600".parse::<HeaderValue>().unwrap()) //Any)
|
||||
.allow_headers(vec![ORIGIN, AUTHORIZATION, ACCEPT, CONTENT_TYPE, COOKIE])
|
||||
.allow_origin([
|
||||
"http://localhost:54600".parse().unwrap(),
|
||||
"http://localhost:5173".parse().unwrap(),
|
||||
]) //Any)
|
||||
.allow_credentials(true); //"http://localhost:5173".parse::<HeaderValue>().unwrap());
|
||||
|
||||
let app = Router::new()
|
||||
@ -75,10 +78,6 @@ async fn main() {
|
||||
.route("/assets/*file", get(static_handler))
|
||||
.route("/api/v1/register_user", post(api::v1::register_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(
|
||||
"/api/v1/me",
|
||||
get(api::v1::me).route_layer(middleware::from_fn_with_state(
|
||||
@ -86,6 +85,10 @@ async fn main() {
|
||||
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(
|
||||
TraceLayer::new_for_http()
|
||||
.make_span_with(trace::DefaultMakeSpan::new().level(Level::INFO))
|
||||
@ -109,6 +112,8 @@ async fn user_login() -> impl IntoResponse {
|
||||
frontend::BaseTemplate { view: "signin" }
|
||||
}
|
||||
|
||||
async fn user(Path(user): Path<String>) -> impl IntoResponse {}
|
||||
|
||||
async fn users(
|
||||
State(state): State<Arc<AppState>>,
|
||||
) -> Result<Json<Vec<User>>, (StatusCode, Json<serde_json::Value>)> {
|
||||
|
Loading…
Reference in New Issue
Block a user