#Nuxt Plugin Not Working On First Load?

6 messages · Page 1 of 1 (latest)

main ibex
#
// /plugins/database.js
import { sutando } from "sutando";
import config from "~/sutando.config.cjs";

export default defineNuxtPlugin(() => {
    sutando.addConnection(config);
    sutando.connection();
});

When I go to a server route using Sutando, the first load errors like it's missing the config, one all reloads after that it works fine.

How can I change my plugin to auto import this and set it up?

west mango
#

If this should be accessible in your server routes (so /server folder) you need a nitro plugin

main ibex
#

@west mango what if I want it on both frontend and backend? The thing is it works fine but not on the first load for a server endpoint. So should it be a Nitro plugin also? I'm kinda confused about that

west mango
main ibex