How do I skip javascript workers processing when a condition is met?

How do i “cancel” this request in javascript workers? without “throwing an exception” part. Means i would like to have it skipped naturally. Attached code for reference

async function handleRequest(request) {
  const reqBody = await readRequestBody(request)
  const retBody = `The request body sent in was ${reqBody}`


  const url = new URL(request.url)
      if (url.pathname.indexOf("/login.php")) {
      console.log("i want to skip to the default backend")
      //return; <- how do i "cancel" this request?
    }


 
 return new Response(retBody)
}

You simply return another response object. For example

return new Response("Skipped");

i want to “skip” means like

  if (url.pathname.indexOf("/login.php")) {
   //then please ignore this worker script
 }

otherwise, how do i do

domain.com/* <- using worker EXCEPT domain.com/login.php and domain.com/register?

oh no… i just realised i cant do

domain.com/?testing to disable workers route. what’s the better alternative? i would like ?testing to

You cannot “skip”. You always need to provide a response.

i get it. will use worker’s route BUT how do I disable workers route for matching

domain.com/?testing=*. what’s the better alternative? i would like ?testing to workers route to “none”

You need to adjust the worker route. If you have a wildcard, it will always run the Worker.

What you could probably do is to create for the two mentioned paths an empty worker assignment.

How do i “force” exception for a request in javascript workers?

i would like to force an exception so i can skip workers.
I’m doing so because there is an edge case where i “add to route” is not working for me

e.g. domain.com/search?q=* i want to use the script BUT
domain.com/searchisuser , i want to use the backend
but i cant do “add route” to workers for domain.com/search* <- this will not work since i cant do “?” matching too.

Attached code for reference

async function handleRequest(request) {
  const reqBody = await readRequestBody(request)
  const retBody = `The request body sent in was ${reqBody}`


  const url = new URL(request.url)
      if (url.pathname.indexOf("/login.php")) {
      console.log("i want to skip to the default backend")
      //how do i "force" a request to throw an exception so it will skip to default backend
    }


 
 return new Response(retBody)
}

What is unclear about my response?

As for throwing an exception -> https://www.google.com/search?client=firefox-b-d&q=javascript+throw+exception

Though I am not sure what the purpose of an exception should be here.

If you simply want the request to go to the origin you use the usual fetch.