预设选项
使用对应的部署预设时生效的平台专属选项。
Note
本页所有示例都假设已在 nitro.config.ts 中导入以下内容:
import { defineConfig } from "nitro";#awsAmplify
AWS Amplify 预设的选项。主要字段包括 catchAllStaticFallback、imageOptimization(path、cacheControl)、imageSettings 和 runtime(nodejs20.x、nodejs22.x 或 nodejs24.x,默认值为 nodejs22.x)。参见预设文档。
export default defineConfig({
awsAmplify: {
runtime: "nodejs22.x",
imageOptimization: { path: "/_image", cacheControl: "public, max-age=3600" },
},
});#awsLambda
AWS Lambda 预设的选项。将 streaming 设为 true 可启用响应流。参见预设文档。
export default defineConfig({
awsLambda: {
streaming: true,
},
});#azure
Azure Static Web Apps 预设的选项。使用 config 自定义生成的 staticwebapp.config.json(例如 platform.apiRuntime、navigationFallback)。参见预设文档。
export default defineConfig({
azure: {
config: { platform: { apiRuntime: "node:20" } },
},
});#firebase
Firebase App Hosting 预设的选项。使用 appHosting 自定义生成的运行配置。参见预设文档。
export default defineConfig({
firebase: {
appHosting: {
memoryMiB: 512,
maxInstances: 10,
},
},
});#iis
IIS 预设的选项。使用 mergeConfig 将生成的 web.config 与现有配置合并,或使用 overrideConfig 完全替换现有配置。参见预设文档。
export default defineConfig({
iis: {
mergeConfig: true,
},
});#netlify
Netlify 预设的选项。使用 config 提供 Netlify部署配置(headers、redirects、functions、edge_functions、images 等)。参见预设文档。
export default defineConfig({
netlify: {
config: {
redirects: [{ from: "/old", to: "/new", status: 301 }],
},
},
});#vercel
Vercel 预设的选项。参见预设文档。
export default defineConfig({
vercel: {
config: { runtime: "nodejs20.x" },
},
});#cloudflare
Cloudflare 预设的选项。参见预设文档。
export default defineConfig({
cloudflare: {
wrangler: { compatibility_date: "2025-01-01" },
},
});#zephyr
Zephyr 预设的选项。参见预设文档。