about summary refs log tree commit diff
path: root/src/lib/api/debug-appview-proxy-header.ts
diff options
context:
space:
mode:
authorAnsh <anshnanda10@gmail.com>2023-06-14 15:20:46 -0700
committerGitHub <noreply@github.com>2023-06-14 17:20:46 -0500
commit775b5e6578e5567bee333fc776b8f38072214832 (patch)
tree0e34e9e2fc6ec3ee0bb80dd6b5542cac5c30f6ac /src/lib/api/debug-appview-proxy-header.ts
parent272ddeb7e21e5c8bf4f125b6b2e3bb8f53e47586 (diff)
downloadvoidsky-775b5e6578e5567bee333fc776b8f38072214832.tar.zst
add checks to make sure we are on web (#879)
Diffstat (limited to 'src/lib/api/debug-appview-proxy-header.ts')
-rw-r--r--src/lib/api/debug-appview-proxy-header.ts8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/lib/api/debug-appview-proxy-header.ts b/src/lib/api/debug-appview-proxy-header.ts
index d84f65cc1..39890b7c3 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<boolean>(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'
 }