Taylan
Taylan
NNuxt
Created by Taylan on 11/11/2024 in #❓・help
Scheduling tasks after server startup
Most of the implementations are using plugins for sheduling libraries but in my case users should be able to create and run tasks and these tasks should be run only once. So, in this case, tasks are scheduled after startup and since plugins are executed during startup, how can achieve this with agenda.js for example? I also checked Nitro's scheduler but it seems it also does not fit for my case. Should i put this logic outside of Nuxt environment?
8 replies
NNuxt
Created by Taylan on 10/3/2024 in #❓・help
getServerSession() returns null on server middleware
Hi,
import { getServerSession, getToken } from '#auth';

export default eventHandler(async (event) => {
const session = await getServerSession(event);
if (!session) {
throw createError({
statusMessage: 'Unauthenticated',
statusCode: 403
});
}
});
import { getServerSession, getToken } from '#auth';

export default eventHandler(async (event) => {
const session = await getServerSession(event);
if (!session) {
throw createError({
statusMessage: 'Unauthenticated',
statusCode: 403
});
}
});
inside of server/middleware/auth.ts returns null on same cases. There was a warning about it and recommended solution was to pass cookies to headers and i have already applied it during any request. But still, especially on page refresh, session returns null. Also, i realized that if there is a async fetch call inside of any .vue component's onMounted() method, this middleware is called. Ex: if there are 4 calls it is called 4 times even if i dont mount that page. Any recommendations to overcome this issue?
5 replies