NUXT SITEMAP- example.com/sitemap.xml layer0托管上不存在

发布于 2025-01-29 10:47:11 字数 1691 浏览 2 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

驱逐舰岛风号 2025-02-05 10:47:11

默认情况下文件到.layer0路径。为了解决此问题,我们必须将几行添加到layer0.config.js

'use strict'

// This file was automatically added by layer0 deploy.
// You should commit this file to source control.

module.exports = {
  backends: {
    origin: {
      domainOrIp: 'layer0-origin.example.com',
    },
  },
  includeNodeModules: true,
  connector: '@layer0/nuxt',
  // include the required file
  includeFiles: {
    '.nuxt/dist/sitemap-routes.json': true,
  },
}

然后文件将如下

By default layer0 configuration not include ".nuxt/dist/sitemap-routes.json" file into .layer0 path. In order to fix this we have to add few code lines to layer0.config.js.

'use strict'

// This file was automatically added by layer0 deploy.
// You should commit this file to source control.

module.exports = {
  backends: {
    origin: {
      domainOrIp: 'layer0-origin.example.com',
    },
  },
  includeNodeModules: true,
  connector: '@layer0/nuxt',
  // include the required file
  includeFiles: {
    '.nuxt/dist/sitemap-routes.json': true,
  },
}

then the file will be there as below
enter image description here

谁与争疯 2025-02-05 10:47:11

如果您将SSR与NUXT一起使用,请让NUXT提供站点地图,而不是使用npm Run生成创建的静态文件。将以下内容添加到您的layer0路由器:

.match('/sitemap.xml', ({ renderWithApp }) => {
  renderWithApp()
})

我已经更新了我们的文档: https://docs.layer0.co/guides/nuxt#serving-sitemap-with-ssr

If you are using SSR with Nuxt, let Nuxt serve the sitemap instead of the static file you would had created with npm run generate. Add the following to your Layer0 router:

.match('/sitemap.xml', ({ renderWithApp }) => {
  renderWithApp()
})

I've updated our documentation with this information: https://docs.layer0.co/guides/nuxt#serving-sitemap-with-ssr

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文