Fix: JWT session strategy + image optimalisatie uit voor ARM
All checks were successful
Build & Deploy / build (push) Successful in 1m41s
All checks were successful
Build & Deploy / build (push) Successful in 1m41s
This commit is contained in:
@@ -2,6 +2,9 @@
|
|||||||
const nextConfig = {
|
const nextConfig = {
|
||||||
output: "standalone",
|
output: "standalone",
|
||||||
images: {
|
images: {
|
||||||
|
// Sharp is moeilijk te installeren op ARM Alpine,
|
||||||
|
// voor Discord avatars is optimalisatie niet nodig
|
||||||
|
unoptimized: true,
|
||||||
remotePatterns: [
|
remotePatterns: [
|
||||||
{
|
{
|
||||||
protocol: "https",
|
protocol: "https",
|
||||||
|
|||||||
@@ -5,6 +5,11 @@ import { prisma } from "./prisma";
|
|||||||
|
|
||||||
export const authOptions: NextAuthOptions = {
|
export const authOptions: NextAuthOptions = {
|
||||||
adapter: PrismaAdapter(prisma),
|
adapter: PrismaAdapter(prisma),
|
||||||
|
// JWT strategy zodat de middleware de sessie kan verifieren
|
||||||
|
// zonder een database call te doen bij elk request
|
||||||
|
session: {
|
||||||
|
strategy: "jwt",
|
||||||
|
},
|
||||||
providers: [
|
providers: [
|
||||||
DiscordProvider({
|
DiscordProvider({
|
||||||
clientId: process.env.DISCORD_CLIENT_ID!,
|
clientId: process.env.DISCORD_CLIENT_ID!,
|
||||||
@@ -12,9 +17,16 @@ export const authOptions: NextAuthOptions = {
|
|||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
callbacks: {
|
callbacks: {
|
||||||
session({ session, user }) {
|
jwt({ token, user }) {
|
||||||
|
// user is alleen aanwezig bij eerste login
|
||||||
|
if (user) {
|
||||||
|
token.id = user.id;
|
||||||
|
}
|
||||||
|
return token;
|
||||||
|
},
|
||||||
|
session({ session, token }) {
|
||||||
if (session.user) {
|
if (session.user) {
|
||||||
session.user.id = user.id;
|
session.user.id = token.id as string;
|
||||||
}
|
}
|
||||||
return session;
|
return session;
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user