Insecure HTTPS Proxy

Proxies HTTPS requests without validating the SSL Certificate.

Example usage - https://unsecure-fetch.val-town.workers.dev/?url=https%3A%2F%2Fassignment-api.uspto.gov%2Fpatent%2FbasicSearch%3Fquery%3D1234567%26fields%3Dmain%26rows%3D20

My source:

async function fetch(request, env, ctx) {
 const url = new URL(request.url);
 const newURL = url.searchParams.get("url")
 console.log(newURL)
 if (!newURL?.length) {
  return new Response(
    `<h1>Insecure HTTPS Proxy</h1>
    <div>Proxies HTTPS requests without validating the SSL Certificate.</div>
    <br>
    <div>Example usage - <a href="${exampleURL}">${exampleURL}</a></div>
    <h1>My source:</h1>
   <pre>${escape(this.fetch.toString().replaceAll(" ", " "))}</pre>
    `
    , {
   headers: {
    "content-type": "text/html"
   }
  })
 }
 try {
  const newReq = new Request(newURL, request)
  const resp = await globalThis.fetch(newReq)
  return resp
 } catch (e) {
  return Response.json({ message: e.message, stack: e.stack})
 }
}