asyncfunctionhandleRequest(request) { // Fetch the original request const response = awaitfetch(request);
// If it's an image, engage hotlink protection based on the // Referer header. const referer = request.headers.get('Referer'); const contentType = response.headers.get('Content-Type') '';
if (referer && contentType.startsWith(PROTECTED_TYPE)) { // If the hostnames don't match, it's a hotlink let refHostname = newURL(referer).hostname if (!refHostname.endsWith('limour.top') && !refHostname.endsWith('j11.fun')) { // Redirect the user to your website returnResponse.redirect(HOMEPAGE_URL, 302); } }
// Everything is fine, return the response normally. return response; }