feat: root files from the CMS and the 404 report
- server/middleware/seo-root.ts proxies /robots.txt, /sitemap.xml, /sitemap-<name>.xml, /llms.txt and the verification and IndexNow key files the site answer lists in root_files, with the backend's status, content type and X-Robots-Tag; a backend failure is 503 Retry-After 60 - server/lib/site.ts caches GET /_seo/api/v1/site (300 s, cleared by the purge); a backend without it (404) keeps the v0.1.1 behaviour: no root proxies, the verification lookup by name - the 404 report and the verification lookup honour seo.cms and rootFiles - smoke runs for the layer off (seo.cms and the v0.1.1 enabled switch), the CMS down (fail open) and no 404 token; npm run purge:check
This commit is contained in:
9
testing/expect-seo-down.txt
Normal file
9
testing/expect-seo-down.txt
Normal file
@@ -0,0 +1,9 @@
|
||||
# The CMS unreachable (NUXT_SEO_API_BASE on a closed port): pages render
|
||||
# normally with their own head (fail open); a root file is 503 with
|
||||
# Retry-After, so crawlers retry; verification lookups fall through.
|
||||
200 /about contains=<title>Own about | Playground</title> notcontains=About us | Acme noheader=X-Robots-Tag count=application/ld+json:0
|
||||
200 /plain contains=<title>Plain page | Playground</title>
|
||||
503 /robots.txt header=Retry-After: 60
|
||||
503 /sitemap-posts-1.xml header=Retry-After: 60
|
||||
404 /google0123.html
|
||||
apicalls 0
|
||||
3
testing/expect-seo-notoken.txt
Normal file
3
testing/expect-seo-notoken.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
# No 404 token (NUXT_SEO_NOTFOUND_TOKEN empty): a 404 page sends no report.
|
||||
404 /kontakt
|
||||
noreport /kontakt
|
||||
13
testing/expect-seo-off.txt
Normal file
13
testing/expect-seo-off.txt
Normal file
@@ -0,0 +1,13 @@
|
||||
# The layer switched off: seo.cms false (NUXT_PUBLIC_SEO_CMS=false) or the
|
||||
# v0.1.1 switch public.seo.enabled false (NUXT_PUBLIC_SEO_ENABLED=false).
|
||||
# No resolve, no CMS head, no redirect, no root files, no 404 report: the
|
||||
# pages keep their own head and the API sees no request at all.
|
||||
200 /about contains=<title>Own about | Playground</title> contains=href="https://own-canonical.test/about" noheader=X-Robots-Tag
|
||||
200 /plain?page=abc contains=<title>Plain page | Playground</title>
|
||||
404 /stary noheader=Location
|
||||
404 /robots.txt
|
||||
404 /google1234.html
|
||||
404 /google0123.html
|
||||
404 /kontakt
|
||||
apicalls 0
|
||||
noreport /kontakt
|
||||
@@ -39,3 +39,27 @@ resolves /stary 1
|
||||
200 /api/__seo__/resolve?url=/blog/lwia-grzywa contains="title":"Lwia grzywa | Example" header=X-Robots-Tag: noindex
|
||||
resolves /blog/lwia-grzywa 1
|
||||
422 /api/__seo__/resolve?url=https://evil.test/
|
||||
|
||||
# Root files from the backend, with its status, content type and
|
||||
# X-Robots-Tag; a backend failure is 503 with Retry-After.
|
||||
200 /robots.txt contains=Disallow: /konto type=text/plain header=X-Content-Type-Options: nosniff
|
||||
200 /sitemap.xml contains=<sitemapindex type=application/xml
|
||||
200 /sitemap-posts-1.xml contains=<urlset type=application/xml header=X-Robots-Tag: noindex
|
||||
200 /llms.txt contains=Fixture llms.txt header=X-Robots-Tag: noindex
|
||||
404 /sitemap-missing-1.xml
|
||||
503 /sitemap-fail-1.xml header=Retry-After: 60
|
||||
# Listed root files: a verification file and the IndexNow key file.
|
||||
200 /google1234.html contains=google-site-verification: google1234.html header=X-Robots-Tag: noindex header=X-Content-Type-Options: nosniff
|
||||
200 /a1b2c3d4e5f60718293a4b5c6d7e8f90.txt contains=a1b2c3d4e5f60718293a4b5c6d7e8f90 type=text/plain
|
||||
# Not listed: passes through to Nuxt, which renders its 404 (the route
|
||||
# middleware resolves it; no verification lookup is made).
|
||||
404 /random.txt
|
||||
404 /google0123.html
|
||||
404 /kontakt
|
||||
|
||||
# 404 pages report themselves once with the bearer token; a 410 or a
|
||||
# redirect does not.
|
||||
report /kontakt
|
||||
report /nieznana-strona
|
||||
noreport /usuniety
|
||||
noreport /stary
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
a1b2c3d4e5f60718293a4b5c6d7e8f90
|
||||
3
testing/fixtures/seo/root/llms.txt
Normal file
3
testing/fixtures/seo/root/llms.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
# Example
|
||||
|
||||
> Fixture llms.txt
|
||||
3
testing/fixtures/seo/root/robots.txt
Normal file
3
testing/fixtures/seo/root/robots.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
User-agent: *
|
||||
Disallow: /konto
|
||||
Sitemap: https://example.test/sitemap.xml
|
||||
2
testing/fixtures/seo/root/sitemap-posts-1.xml
Normal file
2
testing/fixtures/seo/root/sitemap-posts-1.xml
Normal file
@@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><url><loc>https://example.test/blog/lwia-grzywa</loc></url></urlset>
|
||||
2
testing/fixtures/seo/root/sitemap.xml
Normal file
2
testing/fixtures/seo/root/sitemap.xml
Normal file
@@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><sitemap><loc>https://example.test/sitemap-posts-1.xml</loc></sitemap></sitemapindex>
|
||||
13
testing/fixtures/seo/site.json
Normal file
13
testing/fixtures/seo/site.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"site_url": "https://example.test",
|
||||
"default_locale": "pl",
|
||||
"locales": ["pl", "en"],
|
||||
"unprefixed_locale": "pl",
|
||||
"links": { "new_tab": true },
|
||||
"html_sitemap": { "enabled": true, "paths": { "pl": "/mapa-strony", "en": "/en/sitemap" }, "page_size": 100 },
|
||||
"routes": [{ "type": "post", "pattern": "/blog/:slug" }],
|
||||
"root_files": ["google1234.html", "a1b2c3d4e5f60718293a4b5c6d7e8f90.txt"],
|
||||
"llms": true,
|
||||
"pagination": { "form": "query", "param": "page", "segments": {} },
|
||||
"home_crumb": { "name": "Start", "url": "https://example.test/" }
|
||||
}
|
||||
1
testing/fixtures/seo/verification/google1234.html
Normal file
1
testing/fixtures/seo/verification/google1234.html
Normal file
@@ -0,0 +1 @@
|
||||
google-site-verification: google1234.html
|
||||
Reference in New Issue
Block a user