Michal Szorád
Michal Szorád

Reputation: 215

AdSense on NextJS and Vercel project says Ads.txt not found

It's been a couple of weeks since I started integrating AdSense on my NextJS and Vercel project, however AdSense keeps saying "Ads.txt not found" along with "Earnings at risk - You need to fix some ads.txt file issues to avoid severe impact to your revenue.".

The approval status on my website on AdSense is "Ready".

When I visit non www website, I'm redirected to www website and the ads.txt shows correctly. When I visit HTTP version of the website, I'm redirected to HTTPS and the ads.txt shows correctly.

Eg when I visit http://mywebsite.com/ads.txt, I'm redirected to https://www.mywebsite.com/ads.txt and the ads.txt shows correctly.

The ads.txt file is placed into /public/ads.txt in the project structure.

The https://www.mywebsite.com/ads.txt is indexed on Google. I've checked this on Google Search Console.

Do you have any idea how to resolve this issue?

I would expect the error message to disappear.

Upvotes: 7

Views: 1323

Answers (1)

Yusup
Yusup

Reputation: 41

enter image description here

If you are using vercel as your website distribution tool, choose the option that is not the www.yourdomain.com redirect method, because this is also related to

https://support.google.com/adsense/troubleshooter/9556696?sjid=4393915934782411537-AP#ts=9805619%2C9816534%2C9817103%2C9817628%2C9817199%2C9817631

To strengthen it, you can also set it in robots.txt so that /ads.txt is allowed to be accessed and indexed by Google crawl.

enter image description here

Here is the syntax in robots.ts

export default function robots() {
return {
    rules: [
        {
            userAgent: '*',
            allow: ['/', '/ads.txt'],
            disallow: ['/privacy-policy'],
        },
    ],
    sitemap: `${process.env.NEXT_PUBLIC_BASE_URL}/sitemap.xml`,
};
}

Upvotes: 0

Related Questions