aboutsummaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorDhravya <[email protected]>2024-04-05 01:14:46 -0700
committerDhravya <[email protected]>2024-04-05 01:14:46 -0700
commit2fce74c54cdad118fcb48d446e5c05c8745861f5 (patch)
tree84fdd5e3e0a8922690764fba9976b3449ca1f828 /apps
parentmemories that show up are legit now (diff)
downloadsupermemory-2fce74c54cdad118fcb48d446e5c05c8745861f5.tar.xz
supermemory-2fce74c54cdad118fcb48d446e5c05c8745861f5.zip
make ext work with dev mode
Diffstat (limited to 'apps')
-rw-r--r--apps/extension/manifest.json4
-rw-r--r--apps/extension/src/App.tsx7
-rw-r--r--apps/extension/src/background.ts8
-rw-r--r--apps/extension/src/util.ts13
4 files changed, 26 insertions, 6 deletions
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/",
"<all_urls>"
]
}
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<z.infer<typeof userObj> | 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() {
<button
onClick={() =>
chrome.tabs.create({
- url: 'https://supermemory.dhr.wtf/api/auth/signin',
+ url: `${backendUrl}/api/auth/signin`,
})
}
id="login"
diff --git a/apps/extension/src/background.ts b/apps/extension/src/background.ts
index 8be462f1..137849b8 100644
--- a/apps/extension/src/background.ts
+++ b/apps/extension/src/background.ts
@@ -1,3 +1,7 @@
+import { getEnv } from "./util";
+
+const backendUrl = getEnv() === "development" ? "http://localhost:3000" : "https://supermemory.dhr.wtf";
+
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
if (request.type === "getJwt") {
chrome.storage.local.get(["jwt"], ({ jwt }) => {
@@ -17,7 +21,7 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
console.error("No JWT found");
return;
}
- fetch("https://supermemory.dhr.wtf/api/store", {
+ fetch(`${backendUrl}/api/store`, {
method: "POST",
headers: {
"Authorization": `Bearer ${jwt}`,
@@ -33,7 +37,7 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
const jwt = request.jwt;
(async () => {
- await fetch("https://supermemory.dhr.wtf/api/ask", {
+ await fetch(`${backendUrl}/api/ask`, {
method: "POST",
headers: {
"Authorization": `Bearer ${jwt}`,
diff --git a/apps/extension/src/util.ts b/apps/extension/src/util.ts
new file mode 100644
index 00000000..b1085edd
--- /dev/null
+++ b/apps/extension/src/util.ts
@@ -0,0 +1,13 @@
+export const getEnv = () => {
+ // chrome.management.getSelf((self) => {
+ // if (self.installType === 'development') {
+ // return "development"
+ // }
+ // else {
+ // return "production"
+ // }
+ // })
+
+ // return null
+ return 'development'
+} \ No newline at end of file