n1koloza
n1koloza

Reputation: 1185

Nextjs 14.2 app router sitemap with redirect has error

Google search console cannot read my sitemap generated by sitemap.ts function. I have tried to change name and path of file, like /sitemap/0.xml, checked if generated xml is correct, but no result.

I had redirect in my next.config which I thought led to the problem.

next.config:

async redirects() {
    return [
      {
        source: '/',
        destination: '/he',
        permanent: true,
      }
    ];
  }

This was curl result:

curl -I https://travel-georgia.club/sitemap.xml
HTTP/2 308
cache-control: public, max-age=0, must-revalidate
content-type: text/plain
date: Wed, 30 Oct 2024 18:04:43 GMT
location: https://www.travel-georgia.club/sitemap.xml
refresh: 0;url=https://www.travel-georgia.club/sitemap.xml
server: Vercel
strict-transport-security: max-age=age-in-seconds
x-vercel-id: vercel-id

I think those are headers that are causing problems:

HTTP/2 308 // may bot thinks it will be redirect loop ? 
content-type: text/plain // must be 'application/xml'
refresh header - i think it can cause some problems?
location header - may also causes some problems?

In robots.txt I have also

Sitemap: https://www.travel-georgia.club/sitemap.xml

I have canonical rel="https://www.travel-georgia.club" meta tag also.

I removed redirects from next.config, added redirect to the root page.

/app/page.tsx

import { redirect } from 'next/navigation';

export default function Page() {
  redirect('/he');
}

But still same result and headers of redirect 308 of /sitemap.xml page.

Why do I still get redirected or how to fix?

Upvotes: 0

Views: 87

Answers (0)

Related Questions