Shampurrrs
Shampurrrs
Explore posts from servers
KKinde
Created by Shampurrrs on 11/19/2024 in #💻┃support
undefined access_token when using session manager with typescript SDK
Hi all! I'm having trouble calling my API in a NextJS Hono server monorepo. I'm wanting to call an API and check for auth but eaverytime I do my server throws a 500 as the access_token from Kinde is undefined in the session manager. Here is my session manager code:
export const sessionManager = (c: Context): SessionManager => ({
async getSessionItem(key: string) {
const result = getCookie(c, key);
console.log("getting session item", key, result);
return result;
},
async setSessionItem(key: string, value: unknown) {
console.log("setting session item", key, value);
const cookieOptions = {
httpOnly: true,
secure: true,
sameSite: "Lax",
} as const;
if (typeof value === "string") {
setCookie(c, key, value, cookieOptions);
} else {
setCookie(c, key, JSON.stringify(value), cookieOptions);
}
},
async removeSessionItem(key: string) {
console.log("removing session item", key);
deleteCookie(c, key);
},
async destroySession() {
console.log("destroying session");
["id_token", "access_token", "user", "refresh_token"].forEach((key) => {
deleteCookie(c, key);
});
},
});
export const sessionManager = (c: Context): SessionManager => ({
async getSessionItem(key: string) {
const result = getCookie(c, key);
console.log("getting session item", key, result);
return result;
},
async setSessionItem(key: string, value: unknown) {
console.log("setting session item", key, value);
const cookieOptions = {
httpOnly: true,
secure: true,
sameSite: "Lax",
} as const;
if (typeof value === "string") {
setCookie(c, key, value, cookieOptions);
} else {
setCookie(c, key, JSON.stringify(value), cookieOptions);
}
},
async removeSessionItem(key: string) {
console.log("removing session item", key);
deleteCookie(c, key);
},
async destroySession() {
console.log("destroying session");
["id_token", "access_token", "user", "refresh_token"].forEach((key) => {
deleteCookie(c, key);
});
},
});
when I console log the getCookie result I get an undefined, but it is defined when setting it. Not sure if my implementation is correct or not. Any help is appreciated. Thanks.
6 replies
TTCTheo's Typesafe Cult
Created by Shampurrrs on 10/5/2023 in #questions
How can I handle multiple files being uploaded, but one or more fails.
Hi! I am trying to upload files using UploadThing, I am able to upload multiple files using the Dropzone component in my nextjs app. The only thing is, say I upload 3 files, and one of them fails because it doesn't meet the size limit. Uploadthing will still upload the other 2 files even though the onUploadComplete function never runs, only the onError function will run. So I will have 3 files in my UploadThing dashboard (2 uploaded and 1 will have failed), but I don't know that the other 2 succeeded. Is there anyway to know when files have uploaded successfully when other files have failed?
1 replies
TTCTheo's Typesafe Cult
Created by Shampurrrs on 9/23/2023 in #questions
CreateTRPCNext<AppRouter> showing typescript error.
No description
4 replies
TTCTheo's Typesafe Cult
Created by Shampurrrs on 10/19/2022 in #questions
How to handle cancelled login, when using nextAuth OAuth?
12 replies