服务器

了解如何将 Nuxt 2 的服务器迁移到 Nuxt 3。

在已构建的 Nuxt 3 应用中,不存在运行时的 Nuxt 依赖。 这意味着你的网站将具有很高的性能并且体积极小。但这也意味着你不能再挂载到运行时 Nuxt 服务端钩子。

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

步骤

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