From da6eb076aa9aaf4e62ca509b599a5f56b2ed5df8 Mon Sep 17 00:00:00 2001 From: Sonia Appasamy Date: Mon, 28 Aug 2023 16:44:48 -0400 Subject: [PATCH] client/web: add localapi proxy Adds proxy to the localapi from /api/local/ web client endpoint. The localapi proxy is restricted to an allowlist of those actually used by the web client frontend. Updates tailscale/corp#13775 Signed-off-by: Sonia Appasamy --- client/web/src/components/app.tsx | 8 +++- client/web/src/components/legacy.tsx | 9 +++- client/web/src/hooks/node-data.ts | 10 ++-- client/web/web.go | 64 ++++++++++++++++++++++++- client/web/web_test.go | 71 ++++++++++++++++++++++++++++ 5 files changed, 152 insertions(+), 10 deletions(-) diff --git a/client/web/src/components/app.tsx b/client/web/src/components/app.tsx index b684615fa..28350e52e 100644 --- a/client/web/src/components/app.tsx +++ b/client/web/src/components/app.tsx @@ -5,7 +5,7 @@ import useNodeData from "src/hooks/node-data" export default function App() { // TODO(sonia): use isPosting value from useNodeData // to fill loading states. - const { data, updateNode } = useNodeData() + const { data, refreshData, updateNode } = useNodeData() return (
@@ -15,7 +15,11 @@ export default function App() { ) : ( <>
-
+
diff --git a/client/web/src/components/legacy.tsx b/client/web/src/components/legacy.tsx index 9d0ec5640..078f5a4bd 100644 --- a/client/web/src/components/legacy.tsx +++ b/client/web/src/components/legacy.tsx @@ -1,5 +1,6 @@ import cx from "classnames" import React from "react" +import { apiFetch } from "src/api" import { NodeData, NodeUpdate } from "src/hooks/node-data" // TODO(tailscale/corp#13775): legacy.tsx contains a set of components @@ -9,9 +10,11 @@ import { NodeData, NodeUpdate } from "src/hooks/node-data" export function Header({ data, + refreshData, updateNode, }: { data: NodeData + refreshData: () => void updateNode: (update: NodeUpdate) => void }) { return ( @@ -89,7 +92,11 @@ export function Header({ {" "} |{" "}