Skip to content

Commit f2c9775

Browse files
techgangbossclaude
andcommitted
fix: use JS redirect instead of meta refresh for share page
Meta refresh content="0" was instant — Twitter's crawler likely followed the redirect before reading the meta tags. Replaced with a JS redirect (window.location.href) which crawlers don't execute. Crawlers read the HTML meta tags, browsers get redirected via JS. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 803027a commit f2c9775

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

src/app/share/preconfirm/route.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { NextRequest, NextResponse } from "next/server"
22

33
/**
44
* Returns raw HTML with OG/Twitter meta tags for share card rendering.
5-
* Twitter's crawler doesn't execute JS, so we can't use generateMetadata.
6-
* Human visitors get redirected to / via meta refresh.
5+
* Crawlers (Twitter, Facebook) read the meta tags.
6+
* Browsers get a JS redirect — crawlers don't execute JS so they stay.
77
*/
88
export async function GET(request: NextRequest) {
99
const raw = parseFloat(request.nextUrl.searchParams.get("time") || "0.4")
@@ -30,9 +30,11 @@ export async function GET(request: NextRequest) {
3030
<meta name="twitter:title" content="${title}" />
3131
<meta name="twitter:description" content="${description}" />
3232
<meta name="twitter:image" content="${ogImage}" />
33-
<meta http-equiv="refresh" content="0;url=/" />
3433
</head>
35-
<body></body>
34+
<body>
35+
<p>Redirecting...</p>
36+
<script>window.location.href="/"</script>
37+
</body>
3638
</html>`
3739

3840
return new NextResponse(html, {

0 commit comments

Comments
 (0)