From ec7fa60469d927820e201551d379504275e19963 Mon Sep 17 00:00:00 2001 From: Shirou-kun Date: Tue, 12 Nov 2024 00:52:52 +0900 Subject: [PATCH] fx: save real ip to notes table --- backend/src/db/index.ts | 1 + backend/src/server.ts | 7 ++----- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/backend/src/db/index.ts b/backend/src/db/index.ts index c4126c71..a3712904 100644 --- a/backend/src/db/index.ts +++ b/backend/src/db/index.ts @@ -22,5 +22,6 @@ export const InitializeDb = () => { console.log("Successful DB connection.") }).catch((err) => { console.error("Error in DB connection: ", err) + process.exit(1) }) } \ No newline at end of file diff --git a/backend/src/server.ts b/backend/src/server.ts index 70b8e0b4..2228d5c2 100644 --- a/backend/src/server.ts +++ b/backend/src/server.ts @@ -35,10 +35,9 @@ const NoteService: NoteServiceHandlers = { ) => { console.log("create a new note..."); const { audio, transcription } = call.request; - console.log(call.getPeer()); - console.log(call.metadata.toJSON()); - const userIp = call.getPeer().split(":")[0]; + const xForwardedFor = call.metadata.get("x-forwarded-for")[0] as string; + const userIp = xForwardedFor ? xForwardedFor.split(",")[0].trim() : call.getPeer().split(":")[0]; if (!transcription) { callback(null, { @@ -77,8 +76,6 @@ const NoteService: NoteServiceHandlers = { callback: grpc.sendUnaryData ) => { console.log("fetching all notes..."); - console.log(call.getPeer()); - console.log(call.metadata.toJSON()); DB.getRepository(DBNote) .find() .then((allNotes) =>