fix: gate /a/:naddr rewrite to crawlers to prevent refresh redirect

- Add conditional rewrite rules in vercel.json to only serve OG HTML to crawlers
- Add ?og=1 query parameter override for manual testing
- Document ?og=1 testing path in README
- Fixes regression where browser refresh on /a/:naddr redirected to root
This commit is contained in:
Gigi
2025-11-07 23:00:12 +01:00
parent 6445445e5d
commit 0bfa0a2e7b
2 changed files with 27 additions and 1 deletions

View File

@@ -79,6 +79,18 @@ If you bookmark something on nostr, Boris will show it in the bookmarks bar. If
- If something looks empty, try opening another article and coming back — network data can arrive in bursts.
- Not every article has highlights yet; they grow as the community reads.
## Development
### Testing Open Graph Previews
To manually test the Open Graph HTML preview for an article, append `?og=1` to any `/a/:naddr` URL:
```text
https://read.withboris.com/a/<naddr>?og=1
```
This bypasses the normal SPA routing and serves the OG preview HTML directly, useful for verifying social media preview cards.
## License
MIT

View File

@@ -11,7 +11,21 @@
"rewrites": [
{
"source": "/a/:naddr",
"destination": "/api/article-og?naddr=:naddr"
"destination": "/api/article-og?naddr=:naddr",
"has": [
{ "type": "query", "key": "og", "value": "1" }
]
},
{
"source": "/a/:naddr",
"destination": "/api/article-og?naddr=:naddr",
"has": [
{
"type": "header",
"key": "user-agent",
"value": ".*(bot|Bot|BOT|crawler|Crawler|CRAWLER|spider|Spider|facebookexternalhit|Slackbot|Twitterbot|LinkedInBot|WhatsApp|TelegramBot|Discordbot|Googlebot|bingbot|YandexBot|Baiduspider).*"
}
]
},
{
"source": "/(.*)",