Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong routes with /_nuxt/ prefix in sitemap #60

Closed
AlexBa opened this issue May 1, 2019 · 8 comments

Comments

@AlexBa
Copy link

commented May 1, 2019

Version
v1.0.0

Reproduction link
https://alexanderbarton.de/sitemap.xml

Steps to reproduce
Just generate the sitemap with the config. :)

What is expected ?
Routes in sitemap without the /_nuxt/ prefix

What is actually happening?
Routes in sitemap with /_nuxt/ prefix

Additional comments?
This is my nuxt.config.js:

const pkg = require('./package');
const dotenv = require('dotenv');

dotenv.config();

module.exports = {
mode: 'universal',

/*
** Headers of the page
*/
head: {
title: pkg.name,
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ hid: 'description', name: 'description', content: pkg.description }
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' },
]
},

/*
** Customize the progress-bar color
*/
loading: false,

/*
** Global CSS
*/
css: [
'~assets/scss/style.scss',
],

/*
** Plugins to load before mounting the App
*/
plugins: [
{src: '~plugins/bootstrap-native', ssr: false},
{src: '~plugins/tiny-slider', ssr: false}
],

/*
** Nuxt.js modules
*/
modules: [
'@nuxtjs/dotenv',
'@nuxtjs/axios',
'@nuxtjs/redirect-module',
['@nuxtjs/google-tag-manager', {
id: process.env.GTM_CONTAINER_ID
}],
['nuxt-i18n', {
strategy: 'prefix_except_default',
defaultLocale: 'de',
lazy: true,
langDir: 'translations/',
locales: [
{
code: 'de',
file: 'de.json'
}
],
}],
'@nuxtjs/sitemap'
],

axios: {
// proxyHeaders: false
},

redirect: [
{ from: '^/datenschutz-erklaerung', to: '/datenschutz' }
],

/*
** Build configuration
*/
build: {
extend(config) {
config.module.rules.push({
test: /bootstrap.native/,
use: {
loader: 'bootstrap.native-loader',
options: {
only: ['collapse', 'modal']
}
}
});
}
}
};

This question is available on Nuxt community (#c49)

@cmty cmty bot closed this May 1, 2019

@cmty cmty bot added the cmty:question label May 1, 2019

@cmty

This comment has been minimized.

Copy link

commented May 1, 2019

This issue as been imported as question since it does not respect sitemap-module issue template. Only bug reports and feature requests stays open to reduce maintainers workload.
If your issue is not a question, please mention the repo admin or moderator to change its type and it will be re-opened automatically.
Your question is available at https://cmty.app/nuxt/sitemap-module/issues/c49.

@AlexBa

This comment has been minimized.

Copy link
Author

commented May 1, 2019

Please note, that I can't report a bug with cmty.app, because there is no version to select in the sitemap module, but this field is required.

@NicoPennec NicoPennec reopened this May 1, 2019

@NicoPennec

This comment has been minimized.

Copy link
Member

commented May 1, 2019

Can you give more details?

  • Nuxt.js version
  • node.js version
  • OS + version
  • command used to generate the sitemap (yarn generate or yarn build && yarn start)

Do you confirm that your sitemap config is empty?

Then, can you removed or disabled the other modules and retry?

To fix your issue quickly, you may use the following workaround:

{
  sitemap: {
    filter ({ routes }) {
      return routes.map(route => route.url = route.url.replace("/_nuxt", ""))
    }
  }
}
@NicoPennec

This comment has been minimized.

Copy link
Member

commented May 1, 2019

@AlexBa Ok, I reproduce when the sitemap: {}configuration object is missing.

@NicoPennec NicoPennec self-assigned this May 1, 2019

@NicoPennec

This comment has been minimized.

Copy link
Member

commented May 1, 2019

@AlexBa for now the better way to fix your issue is to explicitly set the hostname option in your nuxt.config.js file:

{
  sitemap: {
    hostname: "https://alexanderbarton.de"
  }
}

I will check to improve your use case.

@NicoPennec NicoPennec added this to the 1.1 milestone May 1, 2019

@NicoPennec NicoPennec closed this in 56fdddd May 1, 2019

@AlexBa

This comment has been minimized.

Copy link
Author

commented May 2, 2019

@NicoPennec This code seems to work:

{
  sitemap: {
    hostname: "https://alexanderbarton.de"
  }
}

But this code doesn't work (I have tried it before):

{
  sitemap: {
    filter ({ routes }) {
      return routes.map(route => route.url = route.url.replace("/_nuxt", ""))
    }
  }
}

The commands, I tried, were: nuxt and nuxt generate

I just want to provide you some missing info. Maybe it can be helpful for later:

  • Node version: 11.7.0
  • Nuxt version: 2.4.5
  • OS version: maxOS 10.14.4

Thank you for your help!

@NicoPennec

This comment has been minimized.

Copy link
Member

commented May 2, 2019

Thanks for your answer with all details, but as explain before your last post, I found the issue.

It should be fixed since the release v1.1.0, see CHANGELOG

Please update your @nuxtjs/sitemap dependency to the latest release, remove your config `sitemap: { ... } as before, and retry to generate the sitemap.

@AlexBa

This comment has been minimized.

Copy link
Author

commented May 2, 2019

It's working now with v1.1.0. Thank you again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.