nuxt-community / sitemap-module

Sitemap Module for Nuxt 2
https://sitemap.nuxtjs.org
MIT License
690 stars 128 forks source link

sitemap.xml generated in Travis CI build have routes relative to Travis CI build job and not actual routes. #82

Closed liyasthomas closed 5 years ago

liyasthomas commented 5 years ago

Version

2.0

Reproduction link

https://postwoman.io/sitemap.xml

Steps to reproduce

  1. Build nuxt application in Travis CI
  2. Deploy the application
  3. Find the /sitemap.xml generated
  4. Routes are relative to CI build job and not actual routes

What is expected ?

Routes should be relative to base path and not relative to build environment.

What is actually happening?

Instead of base path, build environment is considered as the root and /pages/routes are set relative to build enironment

This bug report is available on Nuxt community (#c68)
liyasthomas commented 5 years ago

sitemap.xml generated from Travis CI build

This XML file does not appear to have any style information associated with it. The document tree is shown below.
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:mobile="http://www.google.com/schemas/sitemap-mobile/1.0" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">
<url>
<loc>
http://travis-job-1c77f852-f86a-4ec6-8538-7abaa8d83c7f/settings
</loc>
</url>
<url>
<loc>
http://travis-job-1c77f852-f86a-4ec6-8538-7abaa8d83c7f/websocket
</loc>
</url>
<url>
<loc>
http://travis-job-1c77f852-f86a-4ec6-8538-7abaa8d83c7f/
</loc>
</url>
</urlset>

See the route locations are relative to build environment rather than base path.

NicoPennec commented 5 years ago

I have checked your nuxt config and you build on spa mode.

In spa and generate mode, the "hostname" option is mandatory, because on build time nuxt can't know your final hostname. It can do it only on universal mode thanks to a Node.js server. see doc: https://github.com/nuxt-community/sitemap-module#hostname-optional---string

I just created a PR to fix your config: https://github.com/liyasthomas/postwoman/pull/177

liyasthomas commented 5 years ago

Thanks for the quick PR 🚀 Issue has been fixed and hence closing.