Pocketbase #530
-
I can't figure out how to use PocketBase auth with app.get("*", async (req, res, next) => {
const pb = new PocketBase("http://localhost:8090") // temp
pb.authStore.loadFromCookie(req.headers.cookie || "")
const pageContextInit = {
urlOriginal: req.originalUrl,
pb,
}
const pageContext = await renderPage(pageContextInit)
const { httpResponse } = pageContext
if (!httpResponse) return next()
const { body, statusCode, contentType, earlyHints } = httpResponse
if (res.writeEarlyHints)
res.writeEarlyHints({ link: earlyHints.map((e) => e.earlyHintLink) })
res.setHeader("set-cookie", pb.authStore.exportToCookie())
res.status(statusCode).type(contentType).send(body)
}) I'm not really sure how to go from here when I try passing it to the client (not sure if I'm supposed to or even if I'm doing it right) I get a Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
Hard to say without seeing your |
Beta Was this translation helpful? Give feedback.
Hard to say without seeing your
_default.page.server.js
and_default.page.client.js
, but I'm guessing you need to addpb
topassToClient
. More info here - https://vite-plugin-ssr.com/passToClient#page-content