Disallow all in robots.txt unless prod (#5078)

This commit is contained in:
Prospector
2026-01-12 03:54:21 -08:00
committed by GitHub
parent f171752109
commit 21045142cd
2 changed files with 13 additions and 3 deletions

View File

@@ -20,6 +20,9 @@ const favicons = {
'(prefers-color-scheme:dark)': '/favicon.ico', '(prefers-color-scheme:dark)': '/favicon.ico',
} }
const PROD_MODRINTH_URL = 'https://modrinth.com'
const STAGING_MODRINTH_URL = 'https://staging.modrinth.com'
export default defineNuxtConfig({ export default defineNuxtConfig({
srcDir: 'src/', srcDir: 'src/',
app: { app: {
@@ -165,6 +168,13 @@ export default defineNuxtConfig({
await fs.writeFile('./src/generated/state.json', JSON.stringify(state)) await fs.writeFile('./src/generated/state.json', JSON.stringify(state))
console.log('Tags generated!') console.log('Tags generated!')
const robotsContent =
getDomain() === PROD_MODRINTH_URL
? 'User-agent: *\nDisallow: /_internal/'
: 'User-agent: *\nDisallow: /'
await fs.writeFile('./src/public/robots.txt', robotsContent)
}, },
}, },
runtimeConfig: { runtimeConfig: {
@@ -329,9 +339,9 @@ function getDomain() {
} else if (process.env.VERCEL_URL) { } else if (process.env.VERCEL_URL) {
return `https://${process.env.VERCEL_URL}` return `https://${process.env.VERCEL_URL}`
} else if (getApiUrl() === STAGING_API_URL) { } else if (getApiUrl() === STAGING_API_URL) {
return 'https://staging.modrinth.com' return STAGING_MODRINTH_URL
} else { } else {
return 'https://modrinth.com' return PROD_MODRINTH_URL
} }
} else { } else {
const port = process.env.PORT || 3000 const port = process.env.PORT || 3000

View File

@@ -1,2 +1,2 @@
User-agent: * User-agent: *
Disallow: /_internal/ Disallow: /