Skip to content

Commit 605ffa1

Browse files
authored
Merge pull request #125 from Friedrich482/features
fix: bearer token transmission
2 parents 5b4ae3b + e366c89 commit 605ffa1

3 files changed

Lines changed: 10 additions & 5 deletions

File tree

apps/api/src/trpc/trpc.service.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ export class TrpcService {
108108
// get jwt token from cookies (browser) or the headers (extension)
109109
const accessToken =
110110
ctx.req.cookies?.auth_token ??
111-
(ctx.req.headers.authorization?.replace("Bearer ", "") || "");
111+
ctx.req.headers.authorization?.replace("Bearer ", "") ??
112+
"";
112113

113114
if (!accessToken) {
114115
throw new TRPCError({

apps/vscode-extension/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "mooncode",
33
"displayName": "MoonCode",
44
"description": "MoonCode is an extension that tracks your coding time (like WakaTime) and gives you a detailed summary about all your coding statistics. With MoonCode, developers get the full history of their coding activity.",
5-
"version": "0.0.57",
5+
"version": "0.0.58",
66
"icon": "./public/moon.png",
77
"publisher": "Friedrich482",
88
"author": {

apps/vscode-extension/src/utils/trpc/client.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,13 @@ export const trpc = createTRPCClient<AppRouter>({
2020
httpBatchLink({
2121
url: getApiURL(),
2222
async headers() {
23-
return {
24-
authorization: `Bearer ${await getToken()}`,
25-
};
23+
const token = await getToken();
24+
25+
return token
26+
? {
27+
authorization: `Bearer ${token}`,
28+
}
29+
: {};
2630
},
2731
transformer: superjson,
2832
}),

0 commit comments

Comments
 (0)