Reverse Proxy Configuration Issue

Hello, I’m new to the Cloudflare and currently am facing an issue in the configuration of a reverse proxy. We have created a dynamic website hosted on our AWS S3 infrastructure. The primary goal is to seamlessly integrate this website as a subpage within a Brand website hosted on an Acquia instance.

To accomplish this, I have created a worker and initial tests conducted in the workers’ development environment indicate that the functionality is operating as expected. However, when we configure this worker to a specific route, such as test.com/subpage, we encounter an issue.

While the page loads content successfully from the AWS S3 instance, the associated Images/CSS/Fonts fail to load. It’s noteworthy that providing absolute paths for assets resolves this issue, but our preference is to have all assets load with relative paths. Unfortunately, this approach has not yielded the desired results.

We are reaching out to leverage your expertise in addressing this challenge. If you have any insights into rectifying the issue with assets loading or if you can propose an alternative and more straightforward method for implementing the reverse proxy, your guidance would be immensely valuable.

here is the worker Code which we have written.

`const pageurl = {
  hostname: "test2.com",
}
 
async function handleRequest(request) {
    const parsedUrl = new URL(request.url)
    const targetPath = parsedUrl.pathname
    const modifiedRequest = new Request(`https://${pageurl.hostname}${targetPath}`, request)
    console.log(modifiedRequest)
    return fetch(modifiedRequest)
}
 
addEventListener("fetch", event => {
  event.respondWith(handleRequest(event.request))
})`