aboutsummaryrefslogtreecommitdiff
path: root/apps/web/app/api
diff options
context:
space:
mode:
authorcodetorso <[email protected]>2024-06-19 08:37:30 -0600
committercodetorso <[email protected]>2024-06-19 08:37:30 -0600
commita7cca293a66e7b042178fa54f182cb887c3e072f (patch)
tree7cd1ab44f2dbed36b296402a6c2ece8d714d00a4 /apps/web/app/api
parentImprove code, failed attempt at Streaming text (diff)
downloadsupermemory-a7cca293a66e7b042178fa54f182cb887c3e072f.tar.xz
supermemory-a7cca293a66e7b042178fa54f182cb887c3e072f.zip
Another Failed Attempt at streaming
Diffstat (limited to 'apps/web/app/api')
-rw-r--r--apps/web/app/api/editorai/route.ts17
1 files changed, 13 insertions, 4 deletions
diff --git a/apps/web/app/api/editorai/route.ts b/apps/web/app/api/editorai/route.ts
index 43d8eb64..5e1fbf0c 100644
--- a/apps/web/app/api/editorai/route.ts
+++ b/apps/web/app/api/editorai/route.ts
@@ -3,6 +3,8 @@ import { ensureAuth } from "../ensureAuth";
export const runtime = "edge";
+// ERROR #2 - This the the next function that calls the backend, I sometimes think this is redundency, but whatever
+// I have commented the auth code, It should not work in development, but it still does sometimes
export async function POST(request: NextRequest) {
// const d = await ensureAuth(request);
// if (!d) {
@@ -11,10 +13,17 @@ export async function POST(request: NextRequest) {
const res : {context: string, request: string} = await request.json()
try {
- const response = await fetch(`${process.env.BACKEND_BASE_URL}/api/editorai?context=${res.context}&request=${res.request}`);
- return new Response(response.body, { status: 200 });
- // const result = await response.json();
- // return new Response(JSON.stringify(result));
+ const resp = await fetch(`${process.env.BACKEND_BASE_URL}/api/editorai?context=${res.context}&request=${res.request}`);
+ // this just checks if there are erros I am keeping it commented for you to better understand the important pieces
+ // if (resp.status !== 200 || !resp.ok) {
+ // const errorData = await resp.text();
+ // console.log(errorData);
+ // return new Response(
+ // JSON.stringify({ message: "Error in CF function", error: errorData }),
+ // { status: resp.status },
+ // );
+ // }
+ return new Response(resp.body, { status: 200 });
} catch (error) {
return new Response(`Error, ${error}`)
}