···
const res = new Response();
10
-
console.log("Cookies:", req.headers.get("cookie"));
11
+
console.log("[/api/me] Request headers:", Object.fromEntries(req.headers.entries()));
12
-
const agent = await getSessionAgent(req, res);
14
-
console.log("No agent found");
15
-
return Response.json(null);
13
+
const agent = await getSessionAgent(req, res);
15
+
console.log("[/api/me] No agent found");
16
+
return new Response(JSON.stringify(null), {
19
+
"Content-Type": "application/json",
20
+
"X-Response-Type": "null"
19
-
console.log("Got agent, checking authentication");
25
+
console.log("[/api/me] Got agent, checking authentication");
const session = await agent.com.atproto.server.getSession();
21
-
console.log("Session info:", {
27
+
console.log("[/api/me] Session info:", {
handle: session.data.handle
const handle = await resolver.resolveDidToHandle(session.data.did);
27
-
console.log("Resolved handle:", handle);
33
+
console.log("[/api/me] Resolved handle:", handle);
29
-
return Response.json({
35
+
const responseData = {
40
+
return new Response(JSON.stringify(responseData), {
43
+
"Content-Type": "application/json",
44
+
"X-Response-Type": "user"
const message = err instanceof Error ? err.message : String(err);
35
-
console.error({ err: message }, "Failed to fetch profile");
36
-
return Response.json(null);
49
+
console.error("[/api/me] Error:", {
51
+
stack: err instanceof Error ? err.stack : undefined,
54
+
headers: Object.fromEntries(req.headers.entries())
57
+
return new Response(JSON.stringify(null), {
60
+
"Content-Type": "application/json",
61
+
"X-Response-Type": "error",
62
+
"X-Error-Message": encodeURIComponent(message)