A development host is kept out of search engines without IAPL_NOINDEX (developmentNoindex, default on)

Separate from the mail rule so that it can be taken or left. A site whose address matches
iapl({ developmentHosts }) - built in: *.dev.netscale.pl - is noindex with no env: robots.txt disallows
everything, pages carry noindex, IndexNow sends nothing, buildSecurityHeaders() adds X-Robots-Tag. Nothing
kept a development copy out of search engines until now unless somebody set the variable.

- iapl({ developmentNoindex: false }) switches it off for the project, IAPL_NOINDEX=0 for one environment
- buildSecurityHeaders({ developmentHosts, serverUrl }): next.config runs before the plugin
- the mail rule keeps its own two signals: the development pattern, and the variable itself
- changelog "what changes on upgrade", deployment.md, security.md, AGENT.md, skills

Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-11-26 10:31:03 +01:00
co-authored by Claude Fable 5.2
parent 14abf369da
commit bc3aac249f
23 changed files with 215 additions and 24 deletions
+10
View File
@@ -75,6 +75,16 @@ describe('IndexNow hook', () => {
expect(fetchSpy).not.toHaveBeenCalled()
})
test('a development host sends nothing, with no variable; IAPL_NOINDEX=0 says otherwise', async () => {
vi.stubEnv('IAPL_NOINDEX', '')
vi.stubEnv('NEXT_PUBLIC_SERVER_URL', 'https://acme.dev.netscale.pl')
await run({ _status: 'published' })
expect(fetchSpy).not.toHaveBeenCalled()
vi.stubEnv('IAPL_NOINDEX', '0')
await run({ _status: 'published' })
expect(fetchSpy).toHaveBeenCalledOnce()
})
test('staging copy (IAPL_NOINDEX) sends nothing even in production', async () => {
vi.stubEnv('IAPL_NOINDEX', '1')
await run({ _status: 'published' })
+4
View File
@@ -877,6 +877,10 @@ describe('the token over time', () => {
// …and mail.relay.developmentHosts wins for the mail service
expect(at('https://acme.dev.netscale.pl', own, { developmentHosts: ['acme.*'] })).toEqual({ by: 'development-host', pattern: 'acme.*' })
expect(at('https://acme.dev.netscale.pl', undefined, { developmentHosts: [] })).toBeNull()
// (that a development host is also kept out of search engines is not the mail service's signal: only the variable is)
vi.stubEnv('NEXT_PUBLIC_SERVER_URL', 'https://acme.dev.netscale.pl')
expect(at('https://acme.dev.netscale.pl', undefined, { developmentHosts: [] })).toBeNull()
vi.stubEnv('NEXT_PUBLIC_SERVER_URL', '')
// either signal is enough; the host is named first
vi.stubEnv('IAPL_NOINDEX', '1')
expect(at('https://client.pl')).toEqual({ by: 'noindex' })
+7
View File
@@ -5,6 +5,7 @@ import { describe, expect, test, vi } from 'vitest'
import type { I18nConfig } from '../src/modules/i18n/types.js'
import { pluginDevelopmentHosts } from '../src/modules/email/relay/options.js'
import { noindexDevelopmentHosts } from '../src/modules/shared/developmentHosts.js'
import { iapl } from '../src/plugin.js'
import { withTotpParts } from './helpers.js'
@@ -31,6 +32,12 @@ describe('iapl — config transform', () => {
expect(await hosts()).toEqual(['*.dev.netscale.pl'])
expect(await hosts(['*.preview.agency-example.com'])).toEqual(['*.preview.agency-example.com'])
expect(await hosts([])).toEqual([])
// the same options reach the helpers that have no config at hand (robots, metadata, IndexNow)
expect(noindexDevelopmentHosts()).toEqual([])
await iapl({ access: { authCollection: 'users' }, developmentNoindex: false, i18n, twoFactor: false })(base())
expect(noindexDevelopmentHosts()).toBe(false)
await iapl({ access: { authCollection: 'users' }, i18n, twoFactor: false })(base())
expect(noindexDevelopmentHosts()).toEqual(['*.dev.netscale.pl'])
})
test('adds globals, endpoint, localization and roles', async () => {
+76
View File
@@ -264,6 +264,82 @@ describe('site-wide noindex (IAPL_NOINDEX) and Markdown headers', () => {
})
})
describe('a development host is noindex without IAPL_NOINDEX (iapl({ developmentHosts, developmentNoindex }))', () => {
const DISALLOW_ALL = { rules: { disallow: ['/'], userAgent: '*' } }
const tag = (args?: Parameters<typeof buildSecurityHeaders>[0]) => buildSecurityHeaders(args).find((h) => h.key === 'X-Robots-Tag')?.value
const load = async () => ({
...(await import('../src/modules/seo/buildMetadata.js')),
...(await import('../src/modules/seo/siteNoindex.js')),
...(await import('../src/modules/shared/developmentHosts.js')),
vi: (await import('vitest')).vi,
})
const DEV = 'https://acme.dev.netscale.pl'
test('robots, the page meta and the header on the built-in development domain, with no variable; the real domain is untouched', async () => {
const { buildMetadata, configureDevelopmentHosts, isSiteNoindex, siteNoindexSignal, vi } = await load()
configureDevelopmentHosts()
vi.stubEnv('IAPL_NOINDEX', '')
vi.stubEnv('IPAL_NOINDEX', '')
try {
expect(buildRobots({ baseUrl: DEV })).toEqual(DISALLOW_ALL)
expect(buildRobots({ baseUrl: 'https://acme.pl' })).not.toEqual(DISALLOW_ALL)
expect(buildMetadata({ baseUrl: DEV, config, locale: 'pl', slugs: { pl: 'x' } }).robots).toEqual({ follow: false, index: false })
expect(buildMetadata({ baseUrl: 'https://acme.pl', config, locale: 'pl', slugs: { pl: 'x' } }).robots).toMatchObject({ index: true })
expect(tag({ serverUrl: DEV })).toBe('noindex, nofollow')
expect(tag({ serverUrl: 'https://acme.pl' })).toBeUndefined()
expect(siteNoindexSignal({ host: DEV })).toBe('development-host')
// helpers that are given no address read NEXT_PUBLIC_SERVER_URL
vi.stubEnv('NEXT_PUBLIC_SERVER_URL', DEV)
expect(tag()).toBe('noindex, nofollow')
expect(isSiteNoindex()).toBe(true)
expect(buildMetadata({ config, locale: 'pl', slugs: { pl: 'x' } }).robots).toEqual({ follow: false, index: false })
vi.stubEnv('NEXT_PUBLIC_SERVER_URL', 'https://acme.pl')
expect(tag()).toBeUndefined()
expect(isSiteNoindex()).toBe(false)
} finally {
vi.unstubAllEnvs()
}
})
test('the switches: IAPL_NOINDEX=0 for one environment, developmentNoindex: false, another list, an empty list', async () => {
const { configureDevelopmentHosts, isSiteNoindex, noindexDevelopmentHosts, siteNoindexSignal, vi } = await load()
vi.stubEnv('IAPL_NOINDEX', '')
vi.stubEnv('IPAL_NOINDEX', '')
try {
configureDevelopmentHosts()
for (const off of ['0', 'false', 'no', 'OFF']) {
vi.stubEnv('IAPL_NOINDEX', off)
expect(buildRobots({ baseUrl: DEV })).not.toEqual(DISALLOW_ALL)
expect(tag({ serverUrl: DEV })).toBeUndefined()
}
vi.stubEnv('IAPL_NOINDEX', '1') // the variable still works everywhere
expect(siteNoindexSignal({ host: 'https://acme.pl' })).toBe('env')
vi.stubEnv('IAPL_NOINDEX', 'maybe') // says nothing: the host decides
expect(isSiteNoindex({ host: DEV })).toBe(true)
vi.stubEnv('IAPL_NOINDEX', '')
configureDevelopmentHosts({ noindex: false }) // iapl({ developmentNoindex: false })
expect(noindexDevelopmentHosts()).toBe(false)
expect(buildRobots({ baseUrl: DEV })).not.toEqual(DISALLOW_ALL)
expect(isSiteNoindex({ host: DEV })).toBe(false)
configureDevelopmentHosts({ hosts: ['*.preview.agency-example.com'] }) // iapl({ developmentHosts: [...] })
expect(buildRobots({ baseUrl: 'https://x.preview.agency-example.com' })).toEqual(DISALLOW_ALL)
expect(buildRobots({ baseUrl: DEV })).not.toEqual(DISALLOW_ALL)
configureDevelopmentHosts({ hosts: [] })
expect(isSiteNoindex({ host: DEV })).toBe(false)
// next.config runs before the plugin: the header builder takes the list itself
expect(tag({ developmentHosts: ['*.preview.agency-example.com'], serverUrl: 'https://x.preview.agency-example.com' })).toBe('noindex, nofollow')
expect(tag({ developmentHosts: false, serverUrl: DEV })).toBeUndefined()
expect(tag({ developmentHosts: [], serverUrl: DEV })).toBeUndefined()
} finally {
configureDevelopmentHosts()
vi.unstubAllEnvs()
}
})
})
describe('createPageMetadata — siteDescription fallback', () => {
// Regresja 1.10.0: readSiteMetaConfig czytał siteDescription, ale nie trafiał do buildMetadata —
// strona bez meta.description nie miała <meta name="description"> (Lighthouse SEO).