question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to prevent trailing slash being added to the paths in additionalPaths

See original GitHub issue

Describe the bug A trailing slash is being added to the paths in additionalPaths. I previously created a bug report but it was closed, assuming it was fixed, I tried with the latest version but still experience the same behaviour so recreating the issue again.

To Reproduce Steps to reproduce the behavior:

  1. Update next-sitemap.js:
module.exports = {
  siteUrl: 'https://example.com',
  generateRobotsTxt: true,
  additionalPaths: async (config) => [
    await config.transform(config, '/additional-page.html'),
  ],
};

  1. Build and export next app
  2. Result:
<url><loc>https://example.com/additional-page.html/</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2021-10-15T07:05:21.440Z</lastmod></url>

Expected behavior It shouldn’t include trailing slash if not needed - <loc>https://example.com/additional-page.html</loc>. When crawlers access the page with trailing slash (e.g. https://example.com/additional-page.html/), the page will break because of the assets it requires. It should be accessed by crawlers without the trailing slash.

Additional context I’m using next-sitemap@1.8.4.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
iamvishnusankarcommented, Feb 23, 2022
0reactions
dominicarrojadocommented, Feb 24, 2022

@iamvishnusankar I’m afraid it is still not fixed: https://codesandbox.io/s/interesting-tu-toztvx?file=/next.config.js

When there’s next.config.js with the trailingSlash: true. the next-sitemap.js config does not override it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to get path without trailing slash or backslash
The following solution works: path = path.strip(r'\/').
Read more >
path.relative adds trailing slash in node 12 #28549 - GitHub
In node 12 we now get a trailing slash. What I expect should happen. We either resolve all paths with or without trailing...
Read more >
gatsby-plugin-force-trailing-slashes
A web-server that treats trailing-slash paths as directories with an index.html inside and non-trailing-slash paths as named documents (and ideally redirects ...
Read more >
Trailing slash in file path results in file not found
Removing the slash fixes it and the folder is found. ... The path in Git is different from the path in windows, you...
Read more >
Edit paths in Adobe Photoshop
Adjust path segments. You can edit a path segment at any time, but editing existing segments is slightly different from drawing them. Keep...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found