Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/461.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在nuxt.js上找不到sitemap.xml的404_Javascript_Nginx_Nuxt.js_Sitemap - Fatal编程技术网

Javascript 在nuxt.js上找不到sitemap.xml的404

Javascript 在nuxt.js上找不到sitemap.xml的404,javascript,nginx,nuxt.js,sitemap,Javascript,Nginx,Nuxt.js,Sitemap,我正在使用nuxt.js生成sitemap.xml 它与本地的npm运行构建和npm运行启动完美配合 然而,当它在使用Nginx的云端时,它将不起作用 这是我的Nginx配置 server { listen 80; server_name vtapau.com www.vtapau.com; location / { proxy_pass http://localhost:8081/;

我正在使用nuxt.js生成sitemap.xml 它与本地的npm运行构建和npm运行启动完美配合

然而,当它在使用Nginx的云端时,它将不起作用

这是我的Nginx配置

server {
        listen 80;
        server_name vtapau.com www.vtapau.com;

        location / {
                proxy_pass http://localhost:8081/;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection 'upgrade';
                proxy_set_header Host $host;
                proxy_redirect off;
        }
}

我面临着完全相同的问题。然后我发现生产服务器中的Nuxt服务器是使用Nuxt start启动的,而不是我在本地使用的Nuxt ts start。这就是我的问题所在。希望这对您有所帮助。

在运行npm运行构建后重新启动PM2服务器。否则,/sitemap.xml将不会出现

我就是这样

站点地图模块的我的配置:

sitemap: {
   hostname: 'https://example.com',
   gzip: true,
   exclude: ['/exampleurl']
}

首先,我真的不知道这是否是对您的有效回答,因为您提到您已经将手动创建的站点地图放入静态文件夹

我认为您错误配置了sitemap,为了使sitemap.xml正常工作,您在sitemap对象内设置了路由:

// nuxt.config.js

{
  sitemap: {
    hostname: 'https://example.com',
    gzip: true,
    exclude: [
      '/secret',
      '/admin/**'
    ],
    routes: [
      '/page/1',
      '/page/2',
      {
        url: '/page/3',
        changefreq: 'daily',
        priority: 1,
        lastmod: '2017-06-30T13:30:00.000Z'
      }
    ]
  }
}
当我被要求选择语言时,我怀疑你的网站地图已经分成了不同的语言。我设法得到了英文版的网站地图

如果您的站点地图配置如下所示:

// nuxt.config.js

{
   sitemap: {
     hostname: 'https://example.com',
     lastmod: '2017-06-30',
     sitemaps: [
       {
          path: '/sitemap-foo.xml',
          routes: ['foo/1', 'foo/2'],
          gzip: true
       }, {
          path: '/folder/sitemap-bar.xml',
          routes: ['bar/1', 'bar/2'],
          exclude: ['/**']
       }
     ]
   }
}
您应该可以在获取站点地图。我希望这不是您创建的静态xml,否则我已经无能为力了。在中明确提到了此文档,当配置错误时,总是返回github文档或通过github问题找到答案

也很高兴看到马来西亚在食品配送方面有了新的初创企业。
我使用Typescript配置文件nuxt.config.ts修复了AWS lambda部署上的相同错误

要修复它,请替换const config:NuxtConfig={}
对于module.exports={}

Hi,我使用pm2启动,它也是nuxt ts start。无论如何,谢谢你的帮助!我已经做到了。不确定这是否是因为我在AWS CodeDeploy中使用bitbucket管道