Sitemap is not showing after adding redirection of www to non-www

I have redirected www domain to non-www domain using the ghost-cli. After adding the redirection in Nginx using ghost-cli I observed that /sitemap.xml stops working and showing an empty page. When I see the console there was logged an error.

Site URL -
Ghost Version - 3.42.2
Browser - Google Chrome
Canonical URL -
Secondary URL -

I have followed the same steps to configure domain redirection given in the Ghost documentation on this page - Ghost-CLI - A fully loaded tool for installation and configuration