SolidJSS
SolidJSโ€ข2y agoโ€ข
6 replies
Shiba Bop

access event.locals from a server function

Hey, I'm new to Solid.js and SolitStart.
I'm trying to implement PocketBase auth and got middleware setup:
export default createMiddleware({
    onRequest: [
        async ({ locals, response, request }) => {
            locals.pb = new PocketBase(process.env.SECURE_PB_URL);

            locals.pb.authStore.loadFromCookie(
                request.headers.get('cookie') || ''
            );

            try {
                locals.pb.authStore.isValid &&
                    (await locals.pb.collection('users').authRefresh());
            } catch {
                locals.pb.authStore.clear();
            }

            response.headers.append(
                'set-cookie',
                locals.pb.authStore.exportToCookie()
            );
        }
    ]
});


is it possible to access event.locals inside a server function?
Was this page helpful?