From 88742141e3cd5f790c9fcc0019af9f5bdeb30798 Mon Sep 17 00:00:00 2001 From: Laurin Weger Date: Thu, 27 Jun 2024 19:10:55 +0200 Subject: [PATCH 1/2] fix: change hard-coded server ip and create note in readme --- .gitignore | 1 + ngaccount/.env | 5 +++++ ngaccount/README.md | 16 ++++++++++++---- ngaccount/src/main.rs | 7 ++++--- ngaccount/web/src/routes/Create.svelte | 2 +- ngaccount/web/src/routes/Delete.svelte | 2 +- 6 files changed, 24 insertions(+), 9 deletions(-) create mode 100644 ngaccount/.env diff --git a/.gitignore b/.gitignore index 33d7186..f1e389f 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ node_modules */tests/*.mnemonic */ng-example/* .vscode/settings.json +.env.local diff --git a/ngaccount/.env b/ngaccount/.env new file mode 100644 index 0000000..3251702 --- /dev/null +++ b/ngaccount/.env @@ -0,0 +1,5 @@ +NG_ACCOUNT_DOMAIN= +NG_ACCOUNT_ADMIN= +NG_ACCOUNT_LOCAL_PEER_KEY= +NG_ACCOUNT_SERVER=127.0.0.1,1440,[the broker's peer ID] +RUST_LOG= diff --git a/ngaccount/README.md b/ngaccount/README.md index 083629b..a0377c0 100644 --- a/ngaccount/README.md +++ b/ngaccount/README.md @@ -12,16 +12,24 @@ pnpm --ignore-workspace install ## Dev -``` +```bash cd web pnpm run dev --host -// in another terminal + +# In another terminal... cd ../ -export NG_ACCOUNT_DOMAIN=[?]; export NG_ACCOUNT_ADMIN=[?]; export NG_ACCOUNT_LOCAL_PEER_KEY=[?]; export NG_ACCOUNT_SERVER=127.0.0.1,14400,[?]; export RUST_LOG=debug + +# Please set the required environment variables in the .env and then source it it with: +source .env + cargo watch -c -w src -x run -// then open http://localhost:5173/ +# Then open http://localhost:5173/#/create ``` +> TODO: +> Currently, the ng-account server api is listening on http://127.0.0.1:3031 only which might cause you trouble. +> See files: `main.rs`, `Create.svelte` and `Delete.svelte`. + ## Prod ``` diff --git a/ngaccount/src/main.rs b/ngaccount/src/main.rs index b0c2772..61ebdc0 100644 --- a/ngaccount/src/main.rs +++ b/ngaccount/src/main.rs @@ -258,7 +258,7 @@ async fn main() -> anyhow::Result<()> { "Content-Security-Policy", HeaderValue::from_static( #[cfg(debug_assertions)] - "default-src 'self' data:; connect-src ipc: https://ipc.localhost 'self' http://192.168.192.2:3031", + "default-src 'self' data:; connect-src ipc: https://ipc.localhost 'self' http://localhost:3031", #[cfg(not(debug_assertions))] "default-src 'self' data:; connect-src ipc: https://ipc.localhost 'self'", @@ -304,9 +304,10 @@ async fn main() -> anyhow::Result<()> { { log_debug!("CORS: any origin"); cors = cors.allow_any_origin(); - log::info!("Starting server on http://192.168.192.2:3031"); + log::info!("Starting server on http://localhost:3031"); warp::serve(api_v1.or(static_files).with(cors).with(incoming_log)) - .run(([192, 168, 192, 2], 3031)) + // TODO: Change this to local network ip? + .run(([127, 0, 0, 1], 3031)) .await; } diff --git a/ngaccount/web/src/routes/Create.svelte b/ngaccount/web/src/routes/Create.svelte index cf7ffe6..4273692 100644 --- a/ngaccount/web/src/routes/Create.svelte +++ b/ngaccount/web/src/routes/Create.svelte @@ -27,7 +27,7 @@ let top; const api_url = import.meta.env.PROD ? "api/v1/" - : "http://192.168.192.2:3031/api/v1/"; + : "http://127.0.0.1:3031/api/v1/"; async function register() { wait = true; diff --git a/ngaccount/web/src/routes/Delete.svelte b/ngaccount/web/src/routes/Delete.svelte index 874bfa7..abcd259 100644 --- a/ngaccount/web/src/routes/Delete.svelte +++ b/ngaccount/web/src/routes/Delete.svelte @@ -27,7 +27,7 @@ let top; const api_url = import.meta.env.PROD ? "api/v1/" - : "http://192.168.192.2:3031/api/v1/"; + : "http://127.0.0.1:3031/api/v1/"; async function bootstrap() {} let error; -- 2.25.1 From 8e8b08d2fcf5f08e12d8aeec9aa5eac887e3dabe Mon Sep 17 00:00:00 2001 From: Laurin Weger Date: Fri, 28 Jun 2024 12:48:43 +0200 Subject: [PATCH 2/2] update readme --- ngaccount/README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ngaccount/README.md b/ngaccount/README.md index a0377c0..7e0a532 100644 --- a/ngaccount/README.md +++ b/ngaccount/README.md @@ -26,9 +26,8 @@ cargo watch -c -w src -x run # Then open http://localhost:5173/#/create ``` -> TODO: -> Currently, the ng-account server api is listening on http://127.0.0.1:3031 only which might cause you trouble. -> See files: `main.rs`, `Create.svelte` and `Delete.svelte`. +> Currently, the ng-account server api is listening on http://127.0.0.1:3031 only which might cause you trouble (coded in `main.rs`, `Create.svelte` and `Delete.svelte`). +> If you need to test from a (virtual) android device, you can use adb to tunnel the connection like: [`adb reverse tcp:3031 tcp:3031`](https://justinchips.medium.com/proxying-adb-client-connections-2ab495f774eb). ## Prod -- 2.25.1