Next.js静态导出时触发‘Server Actions are not supported with static export’错误的排查求助
Next.js静态导出时触发‘Server Actions are not supported with static export’错误的排查求助
我用Next.js搭配Sanity.io客户端做了一个简单的餐厅网站,现在想把它静态导出成纯HTML+CSS+JS文件,这样就不用依赖容器或者Vercel来部署了。但执行导出操作的时候,一直弹出错误:
"Server Actions are not supported with static export"
我已经给项目里的每一个文件都加上了"use client";指令,而且我从一开始就没打算用任何Server Actions功能,但麻烦的是错误信息里完全没指出到底哪里触发了这个问题,我连要改哪里都不知道。
这是我的next.config.ts配置文件:
import type { NextConfig } from "next"; const nextConfig: NextConfig = { output: "export", images: { unoptimized: true, remotePatterns: [ { protocol: "https", hostname: "cdn.sanity.io", }, { protocol: "http", hostname: "cdn.sanity.io", }, ], }, trailingSlash: true, }; export default nextConfig;
有没有人遇到过类似的情况?或者有什么方法能定位到项目里隐性触发Server Actions的地方?比如是不是Sanity的客户端调用里有什么默认会触发Server Actions的配置?
内容来源于stack exchange
相关产品推荐
相关产品推荐

