服务器

学习如何将 Nuxt 2 迁移到 Nuxt 3 服务器。

在构建的 Nuxt 3 应用程序中,没有运行时的 Nuxt 依赖。这意味着您的网站将具有高性能且极其精简。但这也意味着您无法再连接到运行时的 Nuxt 服务器钩子。

Read more in Docs > Guide > Concepts > Server Engine.

步骤

  1. 移除 nuxt.config 中的 render 键。
  2. 位于 ~/server/api~/server/middleware 的任何文件将会被自动注册;您可以将它们从 serverMiddleware 数组中移除。
  3. 更新 serverMiddleware 数组中的任何其他项目,以指向文件或 npm 包,而不是使用内联函数。
Read more in Docs > Guide > Directory Structure > Server.
Read more in Docs > Guide > Going Further > Hooks#server Hooks Runtime.