mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-08-28 05:25:33 +00:00
make ext work with dev mode
This commit is contained in:
parent
db78e5b718
commit
2fce74c54c
4 changed files with 26 additions and 6 deletions
|
|
@ -17,8 +17,8 @@
|
|||
"src/content.tsx"
|
||||
],
|
||||
"matches": [
|
||||
"http://localhost:3000/*",
|
||||
"https://anycontext.dhr.wtf/*",
|
||||
"http://localhost:3000/",
|
||||
"https://anycontext.dhr.wtf/",
|
||||
"<all_urls>"
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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}`,
|
||||
|
|
|
|||
13
apps/extension/src/util.ts
Normal file
13
apps/extension/src/util.ts
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
export const getEnv = () => {
|
||||
// chrome.management.getSelf((self) => {
|
||||
// if (self.installType === 'development') {
|
||||
// return "development"
|
||||
// }
|
||||
// else {
|
||||
// return "production"
|
||||
// }
|
||||
// })
|
||||
|
||||
// return null
|
||||
return 'development'
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue