mirror of
https://github.com/dergigi/boris.git
synced 2025-12-16 22:24:25 +01:00
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:
12
README.md
12
README.md
@@ -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
|
||||
|
||||
16
vercel.json
16
vercel.json
@@ -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": "/(.*)",
|
||||
|
||||
Reference in New Issue
Block a user