希望你们都玩得开心。我正在开发一个简单的 NextJs 应用程序,我想在其中包含多个子域。我正在 vercel 上部署应用程序。
我的应用程序所做的是它有一个简单的文本区域,您可以在其中编写 MDX,单击“发布”按钮,它将将该 MDX 保存到 firebase firestore 中。文本区域下方显示了之前发布的所有页面的列表。
应用程序呈现所有页面的列表,例如随机生成的页面名称作为子域,而实际域稍后出现,如下所示。
a-mdx-page.mydomain.app
Run Code Online (Sandbox Code Playgroud)
当我打开该 URL 时,它将从 firestore 获取页面 MDX 并使用 next-mdx-remote 包序列化和渲染 MDX。使用 next-mdx-remote 包的原因是我们可以在 MDX 中添加 React 组件,并且它可以像普通 React 组件一样渲染。我已经有一个自定义域,因为在 vercel 免费部署中,您无法在免费子域之上拥有子域。
在 localhost 上一切正常,一切都正常,但问题是当我在 Vercel 上部署代码并导航到子域时,它在网站上显示 ERROR 500,并在日志中显示以下错误。
[GET] / 21:21:03:30
2021-10-24T16:21:04.018Z 8e52d5da-ff1f-4840-a09b-199233834a5d ERROR Error: The package "esbuild-linux-64" could not be found, and is needed by esbuild.
If you are installing esbuild with npm, make sure that you don't specify the
"--no-optional" flag. The "optionalDependencies" package.json feature …Run Code Online (Sandbox Code Playgroud)