mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
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.
25 lines
672 B
JavaScript
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;
|
|
},
|
|
};
|