我无法在 nuxt.config.ts 中注册服务器中间件

问题描述 投票:0回答:0

这是我的 nuxt.config.ts 文件

export default defineNuxtConfig({
    css: [
        '@/assets/main.css'
    ],
    serverMiddleware: [
        '~/serverMiddleware/test'
      ]
})

但是 TypeScript 抛出这个错误:

Argument of type '{ css: string[]; serverMiddleware: { path: string; handler: string; }[]; }' is not assignable to parameter of type 'NuxtConfig'.
  Object literal may only specify known properties, and 'serverMiddleware' does not exist in type 'NuxtConfig'.ts(2345)
(property) serverMiddleware: {
    path: string;
    handler: string;
}[]`

我查看了文档和 YouTube,但我找不到如何去做。

nuxt.js nuxtjs3 nuxt3
© www.soinside.com 2019 - 2024. All rights reserved.