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;