// https://nuxt.com/docs/api/configuration/nuxt-config import { IUser } from "@models/user"; import { render } from "vue"; import { rc } from "@server/constants"; import { defineNuxtConfig } from "nuxt/config"; import { fileURLToPath } from "url"; const cac = { isr: true, headersOnly: true, cache: { headersOnly: true, varies: ["Content-Length", "Cookie"], maxAge: 60, }, swr: false, }; export default defineNuxtConfig({ experimental: { watcher: "chokidar-granular", treeshakeClientOnly: true, }, devtools: { enabled: true }, modules: [ "vue-recaptcha/nuxt", "@ant-design-vue/nuxt", "@sidebase/nuxt-auth", "@pinia/nuxt", "@vueuse/nuxt", "@nuxt/test-utils/module", // "@nuxtjs/i18n", ], // i18n: { // vueI18n: `./i18n.config.ts`, // }, antd: { extractStyle: true, }, css: ["~/public/fonts.css", "~/public/css/all.css"], auth: { baseURL: "/api/auth", provider: { type: "refresh", pages: { login: "/auth/login", }, token: { signInResponseTokenPointer: "/token/access", type: "Bearer", headerName: "Authorization", maxAgeInSeconds: 14 * 24 * 60 * 60, }, refreshToken: { signInResponseRefreshTokenPointer: "/token/refresh", }, // @ts-ignore sessionDataType: {} as IUser, endpoints: { signUp: { path: "/register", method: "post" }, signOut: { path: "/logout", method: "post" }, getSession: { path: "/session", method: "get", }, refresh: { path: "/refresh", method: "post", }, }, }, globalAppMiddleware: false, //@ts-ignore session: { enableRefreshPeriodically: 60 * 60 * 2 * 1000, enableRefreshOnWindowFocus: false, }, }, vite: { esbuild: { logLimit: 0, logLevel: "debug", }, logLevel: "info", }, nitro: { esbuild: { options: { minify: true, // loader: "default", logLevel: "verbose", // sourceMap: "inline", }, }, preset: process.env.NODE_ENV == "production" ? "bun" : "node-server", }, routeRules: { "/": cac, "/api/**": { cors: true }, "/band/**": cac, "/authors": cac, "/story/**": { swr: true, isr: true, cache: { maxAge: 1800, headersOnly: true, varies: ["Cookie", "Set-Cookie"], }, }, }, alias: { "@models": fileURLToPath(new URL("./models", import.meta.url)), "@client": fileURLToPath(new URL("./lib/client", import.meta.url)), "@server": fileURLToPath(new URL("./lib/server", import.meta.url)), "@functions": fileURLToPath(new URL("./lib/functions.ts", import.meta.url)), "@dbconfig": fileURLToPath(new URL("./lib/dbconfig.ts", import.meta.url)), "@test": fileURLToPath(new URL("./lib/testing/", import.meta.url)), }, sourcemap: { server: true, client: true, }, runtimeConfig: rc, typescript: { tsConfig: { exclude: ["./.nuxt/types/auth.d.ts"], }, }, imports: { autoImport: true, dirsScanOptions: { types: true, }, }, });