From 1f73a7bf8a75562ccd7d9f099622eedfc13858db Mon Sep 17 00:00:00 2001 From: Austin Drummond Date: Fri, 17 Nov 2023 17:34:36 -0500 Subject: [PATCH] Add a new device registration route (#121) * added a new device registration form * removed unused variables * remove old register html * bind new device key from url * remove redirect * clear nodekey query string param after successuful addition * expand bool flipping * added documention on nodekey * remove null check * tweak wording --- documentation/route_queries.md | 27 +++++++++++++++++++++++++++ src/lib/devices/CreateDevice.svelte | 13 +++++++++++-- src/routes/devices.html/+page.svelte | 7 +++++-- 3 files changed, 43 insertions(+), 4 deletions(-) create mode 100644 documentation/route_queries.md diff --git a/documentation/route_queries.md b/documentation/route_queries.md new file mode 100644 index 0000000..598e474 --- /dev/null +++ b/documentation/route_queries.md @@ -0,0 +1,27 @@ +# Route Queries + +Some routes offer additional behavior to a route when a `?` exists in the URL. These are called query string parameters or route queries. Route queries are used to modify the behavior of a route. Below are the available route queries. + +## Devices + +/devices.html + +### Parameters + +#### `?nodekey={nodekey of a pending device}` + +When this parameter exists, it will automatically open the New Device form and pre-fill the Device Key input automatically. Everything right of the `=` is used as the value of the input. + +Below is an example of how to set up a redirect in NGINX from the default headscale /register/{nodekey} URL to utilize this parameter: + +```nginx + ... + + location /register/nodekey { + rewrite ^/register/(.*)$ /web/devices.html?nodekey=$1 redirect; + } + + location /web { + + ... +``` diff --git a/src/lib/devices/CreateDevice.svelte b/src/lib/devices/CreateDevice.svelte index 7dbe930..d77b968 100644 --- a/src/lib/devices/CreateDevice.svelte +++ b/src/lib/devices/CreateDevice.svelte @@ -1,14 +1,16 @@