Share reward and less robot load on shared links
The first visit of a shared link by someone else earns the sharer one free natal analysis, once per user. The share page reports visits from the visitor's browser; robots, the logged-in sharer and the address the link was made at do not count. The share button is a proper card that says so in small print; /v1/me tells whether the reward is used up. Robots: reading a share writes nothing (view_count counts people only), the frontend keeps shared content for five minutes (cleared when a link is revoked), and robots.txt turns away the known AI crawlers while leaving the link preview robots alone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
// Forwards /api/v1/* to the backend, so the browser talks to one origin and
|
||||
// the session cookie belongs to the frontend's host (no CORS needed).
|
||||
import { revalidateTag } from "next/cache";
|
||||
import type { NextRequest } from "next/server";
|
||||
|
||||
import { BACKEND_URL } from "@/lib/server";
|
||||
import { SHARES_TAG } from "@/lib/share";
|
||||
|
||||
const REQUEST_HEADERS = ["accept", "accept-language", "authorization", "content-type", "cookie", "user-agent"];
|
||||
// Hop-by-hop or re-computed by the runtime.
|
||||
@@ -38,6 +40,8 @@ async function forward(req: NextRequest, ctx: { params: Promise<{ path: string[]
|
||||
if (!SKIP_RESPONSE_HEADERS.has(name)) out.set(name, value);
|
||||
});
|
||||
for (const cookie of res.headers.getSetCookie()) out.append("set-cookie", cookie);
|
||||
// A revoked link must disappear at once from the cached share pages.
|
||||
if (req.method === "DELETE" && path[0] === "shares" && res.ok) revalidateTag(SHARES_TAG, { expire: 0 });
|
||||
return new Response(res.body, { status: res.status, headers: out });
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user