I need to configure that requests that match the domain1.com/test// pattern be serviced by the domain2.com application. Tried to configure it as follows. Created a worker, added code
'''
const redirectMap = new Map([
['/test1', 'domain2.com'],
])
addEventListener('fetch', async event => {
event.respondWith(handleRequest(event.request))
})
async function handleRequest(request) {
let requestURL = new URL(request.url)
let path = requestURL.pathname.split('/redirect')[1]
let location = redirectMap.get(path)
if (location) {
return Response.redirect(location, 301)
}
return fetch(request)
}
'''
After that in the domain settings, I added a worker and specified the site domain1.com/test/*. But it did not work. Help please. Uses instructions https://www.cloudsavvyit.com/3660/how-to-create-a-cloudflare-worker-to-redirect-requests/

