From 2fce74c54cdad118fcb48d446e5c05c8745861f5 Mon Sep 17 00:00:00 2001 From: Dhravya Date: Fri, 5 Apr 2024 01:14:46 -0700 Subject: [PATCH] make ext work with dev mode --- apps/extension/manifest.json | 4 ++-- apps/extension/src/App.tsx | 7 +++++-- apps/extension/src/background.ts | 8 ++++++-- apps/extension/src/util.ts | 13 +++++++++++++ 4 files changed, 26 insertions(+), 6 deletions(-) create mode 100644 apps/extension/src/util.ts diff --git a/apps/extension/manifest.json b/apps/extension/manifest.json index 53bddb24..b8b66cce 100644 --- a/apps/extension/manifest.json +++ b/apps/extension/manifest.json @@ -17,8 +17,8 @@ "src/content.tsx" ], "matches": [ - "http://localhost:3000/*", - "https://anycontext.dhr.wtf/*", + "http://localhost:3000/", + "https://anycontext.dhr.wtf/", "" ] } diff --git a/apps/extension/src/App.tsx b/apps/extension/src/App.tsx index a442cbb9..551fb0d0 100644 --- a/apps/extension/src/App.tsx +++ b/apps/extension/src/App.tsx @@ -1,6 +1,9 @@ import { useEffect, useState } from 'react'; import { z } from 'zod'; import { userObj } from './types/zods'; +import { getEnv } from './util'; + +const backendUrl = getEnv() === "development" ? "http://localhost:3000" : "https://supermemory.dhr.wtf"; function App() { const [userData, setUserData] = useState | null>( @@ -14,7 +17,7 @@ function App() { if (loginButton) { if (jwt) { - fetch('https://supermemory.dhr.wtf/api/me', { + fetch(`${backendUrl}/api/me`, { headers: { Authorization: `Bearer ${jwt}`, }, @@ -43,7 +46,7 @@ function App() {