Hi ,
I am trying to implement script on Workers for any requesting from curl command.
They will be redirected to specific URL. The problem is there is an error as my following script below.
Anyone can help to find the mistakes?
addEventListener("fetch", event => {
event.respondWith(handleRequest(event.request))
})
const newLocation = "https://www.abc123.com"
async function handleRequest(request) {
const reqUA = request.headers.get("User-Agent")
if (reqUA.includes("curl")) {
return Response.redirect(newLocation, 302)
}
return fetch(request)
}