Files
SnapOtter/apps/landing/public/_worker.js
T
SnapOtter 47b6984be0 fix(landing): add www redirect, noindex JS chunks, and website badge
Edge worker 301-redirects www.snapotter.com to snapotter.com to stop
Google from splitting domain authority. Adds X-Robots-Tag: noindex on
/_next/static/ and /_next/data/ paths to reclaim crawl budget wasted
on JS chunks. Adds snapotter.com website badge to README so the
highest-authority backlink (GitHub) points to the main site.
2026-06-13 11:09:02 +08:00

25 lines
672 B
JavaScript

export default {
async fetch(request, env) {
const url = new URL(request.url);
if (url.hostname === "www.snapotter.com") {
url.hostname = "snapotter.com";
return Response.redirect(url.toString(), 301);
}
const response = await env.ASSETS.fetch(request);
if (url.pathname.startsWith("/_next/static/") || url.pathname.startsWith("/_next/data/")) {
const headers = new Headers(response.headers);
headers.set("X-Robots-Tag", "noindex, nofollow");
return new Response(response.body, {
status: response.status,
statusText: response.statusText,
headers,
});
}
return response;
},
};