feat: redirect and 410 enforcement, X-Robots-Tag and the resolve cache
- the Nitro middleware answers redirect (301/302, Location from the answer only, same-site targets as paths as in v0.1.1) and gone (410) before the render and the route cache, sets X-Robots-Tag, and answers 404 for a pagination.invalid answer; other not_found answers stay with Nuxt - resolve answers cached in an LRU (seo.resolveCacheTtl, default 60 s, 1000 entries) with in-flight de-duplication; a clear detaches loads in flight so no answer fetched before a purge is stored after it - the playground route-caches /blog/** (swr 300)
This commit is contained in:
@@ -13,3 +13,29 @@
|
||||
# a new layer node appended; "<" inside the JSON cannot end the script.
|
||||
200 /blog/lwia-grzywa count=data-hid="seo-jsonld":1 count="@type":"WebPage":1 contains="name":"Lwia grzywa" notcontains=Layer name loses contains="inLanguage":"pl" contains=#itemlist
|
||||
200 /blog/lwia-grzywa notcontains=</script><script>alert
|
||||
|
||||
# Redirect decision before the page (and its route cache): the Location
|
||||
# comes from the answer only; a target on the site's origin becomes a path,
|
||||
# another host stays absolute; a crafted Host or X-Forwarded-Host changes
|
||||
# nothing. No X-Robots-Tag on a redirect.
|
||||
301 /stary header=Location: /nowy noheader=X-Robots-Tag
|
||||
301 /stary reqheader=Host: evil.test reqheader=X-Forwarded-Host: evil.test reqheader=X-Forwarded-Proto: http header=Location: /nowy
|
||||
302 /stary-zewnetrzny header=Location: https://partner.test/oferta?a=1
|
||||
# 410 with the app's error page, also on staging with the noindex header.
|
||||
410 /usuniety
|
||||
410 /usuniety-staging header=X-Robots-Tag: noindex, nofollow
|
||||
# A page's x_robots_tag becomes the header.
|
||||
200 /blog/ukryty header=X-Robots-Tag: noindex, nofollow contains=<meta name="robots" content="noindex, nofollow">
|
||||
# not_found: a pagination.invalid answer is a 404 (also on a page that would
|
||||
# render); any other not_found is left to Nuxt's routing.
|
||||
404 /plain?page=abc
|
||||
200 /plain?page=2 contains=<title>Plain page | Playground</title>
|
||||
404 /nieznana-strona
|
||||
|
||||
# The resolve cache: every request above to the tracer page made one call.
|
||||
resolves /blog/lwia-grzywa 1
|
||||
resolves /stary 1
|
||||
# The Nuxt-server resolve route answers through the same cache.
|
||||
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/
|
||||
|
||||
@@ -81,5 +81,103 @@
|
||||
"path": "/blog/lwia-grzywa"
|
||||
}
|
||||
]
|
||||
},
|
||||
"/stary": {
|
||||
"action": "redirect",
|
||||
"status": 301,
|
||||
"location": "https://example.test/nowy",
|
||||
"url": "https://example.test/stary",
|
||||
"locale": "",
|
||||
"staging": false,
|
||||
"seo": null
|
||||
},
|
||||
"/stary-zewnetrzny": {
|
||||
"action": "redirect",
|
||||
"status": 302,
|
||||
"location": "https://partner.test/oferta?a=1",
|
||||
"url": "https://example.test/stary-zewnetrzny",
|
||||
"locale": "",
|
||||
"staging": false,
|
||||
"seo": null
|
||||
},
|
||||
"/usuniety": {
|
||||
"action": "gone",
|
||||
"status": 410,
|
||||
"url": "https://example.test/usuniety",
|
||||
"locale": "",
|
||||
"staging": false,
|
||||
"seo": null
|
||||
},
|
||||
"/usuniety-staging": {
|
||||
"action": "gone",
|
||||
"status": 410,
|
||||
"url": "https://example.test/usuniety-staging",
|
||||
"locale": "",
|
||||
"staging": true,
|
||||
"seo": null
|
||||
},
|
||||
"/plain?page=abc": {
|
||||
"action": "not_found",
|
||||
"status": 404,
|
||||
"url": "https://example.test/plain?page=abc",
|
||||
"locale": "pl",
|
||||
"staging": false,
|
||||
"seo": null,
|
||||
"pagination": {
|
||||
"form": "query",
|
||||
"param": "page",
|
||||
"segment": "",
|
||||
"page": 0,
|
||||
"invalid": true
|
||||
}
|
||||
},
|
||||
"/blog/ukryty": {
|
||||
"action": "ok",
|
||||
"status": 200,
|
||||
"url": "https://example.test/blog/ukryty",
|
||||
"locale": "pl",
|
||||
"staging": false,
|
||||
"seo": {
|
||||
"title": "Ukryty | Example",
|
||||
"description": "Lwia grzywa | Example opis",
|
||||
"canonical": "https://example.test/blog/ukryty",
|
||||
"robots": "noindex, nofollow",
|
||||
"x_robots_tag": "noindex, nofollow",
|
||||
"og": {
|
||||
"title": "Lwia grzywa | Example",
|
||||
"description": "Lwia grzywa | Example opis",
|
||||
"image": "https://example.test/img/og.png",
|
||||
"url": "https://example.test/blog/ukryty",
|
||||
"locale": "pl_PL",
|
||||
"locale_alternates": [
|
||||
"en_US"
|
||||
]
|
||||
},
|
||||
"twitter": {
|
||||
"card": "summary_large_image",
|
||||
"site": "@example"
|
||||
},
|
||||
"verification": []
|
||||
},
|
||||
"html_lang": "pl",
|
||||
"alternates": [],
|
||||
"jsonld": null,
|
||||
"breadcrumbs": [
|
||||
{
|
||||
"name": "Start",
|
||||
"url": "https://example.test/",
|
||||
"path": "/"
|
||||
},
|
||||
{
|
||||
"name": "Blog",
|
||||
"url": "https://example.test/blog",
|
||||
"path": "/blog"
|
||||
},
|
||||
{
|
||||
"name": "Lwia grzywa",
|
||||
"url": "https://example.test/blog/lwia-grzywa",
|
||||
"path": "/blog/lwia-grzywa"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user