Login Google via PocketBase invece che Supabase Auth: nuovi client in src/integrations/pocketbase/ (browser, server con superuser, attacher del bearer token per le server function). Il ruolo admin/user vive ora come campo diretto sul record utente PocketBase invece che nella tabella separata user_roles, quindi ruoli.ts e la verifica in auth-route.server.ts non hanno più bisogno di una query aggiuntiva. requireSupabaseAuth/auth-middleware.ts non viene riportato: non era importato da nessun file, era codice morto. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
32 lines
1.0 KiB
TypeScript
32 lines
1.0 KiB
TypeScript
import { createStart, createCsrfMiddleware, createMiddleware } from "@tanstack/react-start";
|
|
|
|
import { renderErrorPage } from "./lib/error-page";
|
|
import { attachPocketBaseAuth } from "@/integrations/pocketbase/auth-attacher";
|
|
|
|
const errorMiddleware = createMiddleware().server(async ({ next }) => {
|
|
try {
|
|
return await next();
|
|
} catch (error) {
|
|
if (error != null && typeof error === "object" && "statusCode" in error) {
|
|
throw error;
|
|
}
|
|
console.error(error);
|
|
return new Response(renderErrorPage(), {
|
|
status: 500,
|
|
headers: { "content-type": "text/html; charset=utf-8" },
|
|
});
|
|
}
|
|
});
|
|
|
|
// Start installs this automatically when src/start.ts is absent; defining the
|
|
// file opts out, so re-add it explicitly to keep server functions protected
|
|
// from cross-site requests.
|
|
const csrfMiddleware = createCsrfMiddleware({
|
|
filter: (ctx) => ctx.handlerType === "serverFn",
|
|
});
|
|
|
|
export const startInstance = createStart(() => ({
|
|
functionMiddleware: [attachPocketBaseAuth],
|
|
requestMiddleware: [errorMiddleware, csrfMiddleware],
|
|
}));
|