nuxt-modules / robots

Tame the robots crawling and indexing your Nuxt site.
https://nuxtseo.com/robots
412 stars 30 forks source link

404 in Production #114

Closed LeonBuchner closed 9 months ago

LeonBuchner commented 9 months ago

Hey, I am using NuxtJS 3.8.1 and "@nuxtjs/robots": "^3.0.0"

Locally everything is working fine but on my live server I will get a 404 error by nginx when visiting domain.com/robots.txt I am not getting the normal nuxt error page as usual but instead nginx 404 not found.

I am using Cleavr for my Nuxt Deployment.

nuxt.config.ts

modules: [
'~/modules/sitemap',
'nuxt-schema-org',
'@vueuse/nuxt',
'dayjs-nuxt',
'@nuxtjs/robots'
],
robots: {
configPath: 'robots.config'
},

robots.config.ts in my root directory

export default [
  { UserAgent: '*' },
  { Allow: '/' },
  { BlankLine: true },

  { Sitemap: (req) => `https://${req.headers.host}/sitemap.xml` }
]

Any ideas?

LeonBuchner commented 9 months ago

It works now.

My nginx config included the following line location = /robots.txt { access_log off; log_not_found off; }

I commented it out and it works.

#location = /robots.txt { access_log off; log_not_found off; }

Maybe this helps some other people with the same issue.