From 4b068470388481ae21e2c6b80cf6c1bab499698d Mon Sep 17 00:00:00 2001 From: Niko PLP Date: Fri, 16 May 2025 13:42:26 +0300 Subject: [PATCH] fix 401 from localhost. thanks Ani! --- helpers/ngnet/README.md | 2 +- helpers/ngnet/src/main.rs | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/helpers/ngnet/README.md b/helpers/ngnet/README.md index 8ee56240..6ed19939 100644 --- a/helpers/ngnet/README.md +++ b/helpers/ngnet/README.md @@ -28,7 +28,7 @@ pnpm run dev --host cargo watch -c -w src -x run ``` -> Currently, the ngnet server api is listening on http://127.0.0.1:3033 only which might cause you trouble with Android emulator (hardcoded in `main.rs`). +> Currently, the ngnet server api is listening on http://127.0.0.1:3033 only, which might cause you trouble with Android emulator (hardcoded in `main.rs`). > If you need to test from a (virtual) android device, you can use adb to tunnel the connection like: [`adb reverse tcp:3033 tcp:3033`](https://justinchips.medium.com/proxying-adb-client-connections-2ab495f774eb). ## Prod diff --git a/helpers/ngnet/src/main.rs b/helpers/ngnet/src/main.rs index e34d7472..340f548f 100644 --- a/helpers/ngnet/src/main.rs +++ b/helpers/ngnet/src/main.rs @@ -125,7 +125,7 @@ async fn main() -> anyhow::Result<()> { .map(|reply, p: HashMap| match p.get("o") { Some(obj) => { let decoded = obj.trim(); - if BSP_DETAILS.get(decoded).is_none() { + if BSP_DETAILS.get(decoded).is_none() && decoded != "http://localhost:14400" && decoded != "http://localhost:1421" { // rejected (BSP not listed) warp::http::StatusCode::UNAUTHORIZED.into_response() } else { @@ -182,9 +182,11 @@ async fn main() -> anyhow::Result<()> { { cors = cors.allow_origin(NG_NET_URL); cors = cors.allow_origin(NG_APP_URL); + cors = cors.allow_origin("http://localhost:14400"); + cors = cors.allow_origin("http://localhost:1421"); // TODO when there will be an API again, we will call it from any BSPs. // we should add the list of all BSPs origin's here - log::info!("Starting server on http://localhost:3033"); + log::info!("Starting production server on http://localhost:3033"); warp::serve(static_files.or(static_files_auth.or(static_files_bootstrap)).with(cors).with(incoming_log)) .run(([127, 0, 0, 1], 3033)) .await;