'How to submit sitemap-index and child sitemaps in express?

So far I used this option how to generate a sitemap in expressjs

But now that my website has over 50k URLs I need to switch to sitemap index - https://developers.google.com/search/docs/advanced/sitemaps/large-sitemaps

So in express I can't just do:

router.get('/sitemap.xml', function(req, res) {
res.sendFile('YOUR_PATH/sitemap.xml');
});

because now I have multiple files:

/public/sitemaps:
sitemap-index.xml.gz
sitemap-0.xml.gz
sitemap-1.xml.gz
sitemap-2.xml.gz
...

And I need to give google access to all of them, so how can I make it work on express?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source