What is the name of the domain?
What is the error message?
404 alt-svc: h3=“:443”; ma=86400 cf-ray: 8b5df26666e609d6-mia connection: keep-alive content-length: 14 content-type: text/plain;charset=utf-8 date: mon, 19 aug 2024 23:33:08 gmt nel: {“success_fraction”:0,“report_to”:“cf-nel”,“max_age”:604800} report-to: {“endpoints”:[{“url”:“https://a.nel.cloudflare.com/report/v4?s=ifaysvh7fs9h0%2fskhk5ndtqjqsllcw3jhu8uuhfs4xjyzrzxvicjuk7lq87d4jnir3l05v80wxo1sllq287bxwflrcmu9iencgyquxc2cqrlmrzhqdje%2fbg0%2fitamwfmtecqemqs3wmgqy6s39roj7indleqyv7ymsffqjnmtdnuxhhfu75dh1m6g0ggxyw%3d”}],“group”:“cf-nel”,“max_age”:604800} server: cloudflare vary: accept-encoding
What is the issue you’re encountering
ERROR 404
What steps have you taken to resolve the issue?
I would like to create the following: Considering that my site is dynamic, create a Cloudflare Worker that blocks access to URLs not included in your sitemap, you need to write a script that compares incoming requests to a set of allowed paths (extracted from the sitemap). The sitemap would be XML format and that daily checks my sitemap. It detects when a visitor tries to load a non-existent page.
Care must be taken to ensure that your website does not generate 404 errors for normal visitors.
404 errors generated for the following file types will not generate a violation: js, css, gif, jpg, jpeg, png, map, ttf, woff, woff2
const ALLOWED_EXTENSIONS = [‘js’, ‘css’, ‘gif’, ‘jpg’, ‘jpeg’, ‘png’, ‘map’, ‘ttf’, ‘woff’, ‘woff2’];
let allowedURLs = ;
// Function to fetch and parse sitemap
async function updateSitemap(sitemapURL) {
const response = await fetch(sitemapURL);
const xml = await response.text();
const parser = new DOMParser();
const xmlDoc = parser.parseFromString(xml, ‘application/xml’);
const urls = xmlDoc.getElementsByTagName(‘loc’);
allowedURLs = Array.from(urls).map(url => new URL(url.textContent).pathname);
}
// Fetch sitemap daily
addEventListener(‘scheduled’, event => {
event.waitUntil(updateSitemap(‘https://afltest.com/sitemap.xml’));
});
// Main event listener for requests
addEventListener(‘fetch’, event => {
event.respondWith(handleRequest(event.request));
});
async function handleRequest(request) {
const url = new URL(request.url);
const extension = url.pathname.split(‘.’).pop().toLowerCase();
if (ALLOWED_EXTENSIONS.includes(extension) || allowedURLs.includes(url.pathname)) {
return fetch(request);
} else {
return new Response('Page Not Found', { status: 404 });
}
}
// Initial sitemap fetch when the worker starts
addEventListener(‘activate’, event => {
event.waitUntil(updateSitemap(‘https://afltest.com/sitemap.xml’));
});
Was the site working with SSL prior to adding it to Cloudflare?
Yes
What is the current SSL/TLS setting?
Full (strict)
What are the steps to reproduce the issue?
Appear that error I need some help to find the issue and help me to run the worker.