From 9be5321d48a3d2e75b458f2f01e1ff68011bb5f4 Mon Sep 17 00:00:00 2001 From: adueck Date: Tue, 26 Nov 2024 16:53:45 +0500 Subject: [PATCH] try auth a bit --- new-functions/src/index.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/new-functions/src/index.ts b/new-functions/src/index.ts index 77c8ad1..61f1cc7 100644 --- a/new-functions/src/index.ts +++ b/new-functions/src/index.ts @@ -7,9 +7,20 @@ app.get("/", (c) => { return c.text("Hi from hono updated"); }); -app.get("/wa", (c) => { +app.get("/wa", async (c) => { + const cookie = c.req.header("Cookie") || ""; + const r = await fetch("https://account.lingdocs.com/api/user", { + headers: { cookie }, + }); + const { ok, user } = await r.json(); + // const { + // headers: { cookie }, + // } = c. req; + // if (!cookie) { + // return { req: null, res }; + // } // c.env.LINGDOCS_COUCHDB - return c.text("Hi other route"); + return c.json({ ok, user }); }); export default app;