Skip to content

gatsby-plugin-sitemap incorrectly applies assetPath to generated urls #34010

@szimek

Description

@szimek

Preliminary Checks

Description

Our Gatsby site is served from the same domain as some other sites, so I'm setting assetPrefix option to a relative path (/assets/blog) to allow our main nginx server that handles the whole domain to proxy everything that starts with /assets/blog to this site.

The problem is that when I build this site with --prefix-paths option (gatsby build --prefix-paths) gatsby-plugin-sitemap adds assetPrefix every URL in the generated sitemap files.

Additionally, prefixing every page path with assetPath happens outside of any function that I can overwrite.

Reproduction Link

https://github.com/szimek/gatsby-sitemap-asset-prefix-issue

Steps to Reproduce

  1. Run npm run build.
  2. Open the generated public/sitemap/sitemap-0.xml file.
  3. You'll see that the generated urls have /assets prefix, e.g. https://gatsbystarterdefaultsource.gatsbyjs.io/assets/using-dsg.

Expected Result

Urls in the generated sitemap files do not have assetPrefix added, i.e. rather than https://gatsbystarterdefaultsource.gatsbyjs.io/assets/using-dsg I'd expect the url to be https://gatsbystarterdefaultsource.gatsbyjs.io/using-dsg.

Actual Result

Urls in the generated sitemap files do have assetPrefix added, e.g. https://gatsbystarterdefaultsource.gatsbyjs.io/assets/using-dsg.

Environment

System:
    OS: macOS 11.6.1
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.13.0 - /var/folders/3l/fqdyl_w91c71153myktd2r3w0000gn/T/yarn--16371
64001518-0.8952226837346255/node
    Yarn: 1.22.17 - /var/folders/3l/fqdyl_w91c71153myktd2r3w0000gn/T/yarn--16371
64001518-0.8952226837346255/yarn
    npm: 8.1.0 - ~/.nvm/versions/node/v16.13.0/bin/npm
  Languages:
    Python: 2.7.16 - /usr/bin/python
  Browsers:
    Chrome: 95.0.4638.69
    Firefox: 91.0.2
    Safari: 15.1
  npmPackages:
    gatsby: ^4.2.0 => 4.2.0
    gatsby-plugin-gatsby-cloud: ^4.2.0 => 4.2.0
    gatsby-plugin-image: ^2.2.0 => 2.2.0
    gatsby-plugin-manifest: ^4.2.0 => 4.2.0
    gatsby-plugin-offline: ^5.2.0 => 5.2.0
    gatsby-plugin-react-helmet: ^5.2.0 => 5.2.0
    gatsby-plugin-sharp: ^4.2.0 => 4.2.0
    gatsby-plugin-sitemap: ^5.2.0 => 5.2.0
    gatsby-source-filesystem: ^4.2.0 => 4.2.0
    gatsby-transformer-sharp: ^4.2.0 => 4.2.0


Done in 2.64s.

Config Flags

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedIssue with a clear description that the community can help with.topic: pluginsRelated to plugin system, themes & catch-all for plugins that don't have a labeltype: bugAn issue or pull request relating to a bug in Gatsby

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions