From 775b5e6578e5567bee333fc776b8f38072214832 Mon Sep 17 00:00:00 2001 From: Ansh Date: Wed, 14 Jun 2023 15:20:46 -0700 Subject: [PATCH] add checks to make sure we are on web (#879) --- src/lib/api/debug-appview-proxy-header.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/lib/api/debug-appview-proxy-header.ts b/src/lib/api/debug-appview-proxy-header.ts index d84f65cc..39890b7c 100644 --- a/src/lib/api/debug-appview-proxy-header.ts +++ b/src/lib/api/debug-appview-proxy-header.ts @@ -16,6 +16,9 @@ export function useDebugHeaderSetting(agent: BskyAgent): [boolean, () => void] { const [enabled, setEnabled] = useState(isEnabled()) const toggle = useCallback(() => { + if (!isWeb || typeof window === 'undefined') { + return + } if (!enabled) { localStorage.setItem('set-header-x-appview-proxy', 'yes') agent.api.xrpc.setHeader('x-appview-proxy', 'true') @@ -31,7 +34,7 @@ export function useDebugHeaderSetting(agent: BskyAgent): [boolean, () => void] { } export function setDebugHeader(agent: BskyAgent, enabled: boolean) { - if (!isWeb) { + if (!isWeb || typeof window === 'undefined') { return } if (enabled) { @@ -53,5 +56,8 @@ export function applyDebugHeader(agent: BskyAgent) { } function isEnabled() { + if (!isWeb || typeof window === 'undefined') { + return false + } return localStorage.getItem('set-header-x-appview-proxy') === 'yes' }