Skip to content

Commit

Permalink
Merge pull request #15 from MutinyWallet/allow-more-local
Browse files Browse the repository at this point in the history
benthecarman authored Jun 14, 2024
2 parents 4dc9efc + a9e9362 commit 511cfe1
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -31,6 +31,7 @@ const ALLOWED_ORIGINS: [&str; 6] = [

const ALLOWED_SUBDOMAIN: &str = ".mutiny-web.pages.dev";
const ALLOWED_LOCALHOST: &str = "http://127.0.0.1:";
const ALLOWED_LAN: &str = "http://192.168.";

const API_VERSION: &str = "v2";

5 changes: 4 additions & 1 deletion src/routes.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use crate::auth::verify_token;
use crate::kv::{KeyValue, KeyValueOld};
use crate::models::VssItem;
use crate::{State, ALLOWED_LOCALHOST, ALLOWED_ORIGINS, ALLOWED_SUBDOMAIN, API_VERSION};
use crate::{
State, ALLOWED_LAN, ALLOWED_LOCALHOST, ALLOWED_ORIGINS, ALLOWED_SUBDOMAIN, API_VERSION,
};
use axum::headers::authorization::Bearer;
use axum::headers::{Authorization, Origin};
use axum::http::StatusCode;
@@ -244,6 +246,7 @@ pub fn valid_origin(origin: &str) -> bool {
ALLOWED_ORIGINS.contains(&origin)
|| origin.ends_with(ALLOWED_SUBDOMAIN)
|| origin.starts_with(ALLOWED_LOCALHOST)
|| origin.starts_with(ALLOWED_LAN)
}

pub fn validate_cors(origin: Option<TypedHeader<Origin>>) -> Result<(), (StatusCode, String)> {

0 comments on commit 511cfe1

Please sign in to comment.