Detecting curl request to redirect to specific URL

Hi ,

I am trying to implement the script to redirect to specific url whenever requesting from curl command.
But my script has an error which I don’t know what’s wrong as following. Anyone can help ?

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)

}

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)

}