hi all, I am trying to create a worker which proxy to my pages on suffix. I have this code for worke

hi all, I am trying to create a worker which proxy to my pages on suffix. I have this code for worker.js but it is not working as it throws an error as page not found.
// Export a default object containing event handlers
export default {
  // The fetch handler is invoked when this worker receives a HTTP(S) request
  // and should return a Response (optionally wrapped in a Promise)
  async fetch(request) {
    // Parse the request URL
    const url = new URL(request.url);

    // If the request URL matches '/blog1', proxy it to the Cloudflare Pages site
    if (url.pathname.startsWith('/blog1')) {
      // Construct the proxied URL
      const proxiedUrl = 'https://coderabbit-docs.pages.dev' + url.pathname;

      // Proxy the request to the specified URL and return the response
      return fetch(proxiedUrl, request);
    }

    // For other requests, return a default response
    // return new Response('Welcome to my Cloudflare Worker!', {
    //   headers: { 'Content-Type': 'text/plain' },
    // });
  },
};

If I hit my domain with suffix, it goes to 404 .
Was this page helpful?