Goku ごくう
Goku ごくう
NNuxt
Created by Goku ごくう on 10/2/2024 in #❓・help
Netlify deployment with Turborepo mono repo
+ For Vercel users: I'd appreciate it if you're good at Vercel builds!
2 replies
NNuxt
Created by Dawid on 7/2/2024 in #❓・help
Issue with JWT auth in Nuxt 3 SSR
For HttpOnly cookies, here is an example:
const res = await $fetch.raw<Void>(ENDPOINTS.TokenRefresh, {
method: "POST",
baseURL: apiPath,
headers: {
Cookie: authCookieString,
},
});

const setCookieString = res.headers.get("set-cookie") || "";

/**
* `["access_token=...; HttpOnly; ...", "refresh_token=...; HttpOnly; ..."]`
*/
const setCookieArray = splitSetCookieString(setCookieString);

setCookieArray.forEach(cookie => {
appendResponseHeader(event, "set-cookie", cookie);
});
const res = await $fetch.raw<Void>(ENDPOINTS.TokenRefresh, {
method: "POST",
baseURL: apiPath,
headers: {
Cookie: authCookieString,
},
});

const setCookieString = res.headers.get("set-cookie") || "";

/**
* `["access_token=...; HttpOnly; ...", "refresh_token=...; HttpOnly; ..."]`
*/
const setCookieArray = splitSetCookieString(setCookieString);

setCookieArray.forEach(cookie => {
appendResponseHeader(event, "set-cookie", cookie);
});
Auth cookie string is gathered from parseCookies.
5 replies
NNuxt
Created by Dawid on 7/2/2024 in #❓・help
Issue with JWT auth in Nuxt 3 SSR
I am unable to find the resources, but it seems that Pinia cannot be accessed during server-side rendering (SSR), so you will need to create a plugin. I am currently using auth.server.ts under plugins. You can use functions such as useRequestEvent(), appendResponseHeader, and parseCookies from "h3". You can utilize cookies with these functions. Instead of Pinia, I am using useState because it is the safest way for Nuxt payloads, and it works on both the server and client sides.
5 replies