* JavaScript

  ```js
  export default {
    async fetch(request) {
      async function MethodNotAllowed(request) {
        return new Response(`Method ${request.method} not allowed.`, {
          status: 405,
          headers: {
            Allow: "GET",
          },
        });
      }
      // Only GET requests work with this proxy.
      if (request.method !== "GET") return MethodNotAllowed(request);
      return fetch(`https://example.com`);
    },
  };
  ```

  [Run Worker in Playground](https://workers.cloudflare.com/playground#LYVwNgLglgDghgJwgegGYHsHALQBM4RwDcABAEbogB2+CAngLzbPYZb6HbW5QDGU2AAwBmUQDZBARkkAmMQHYxALhYs2wDnC40+AkeKmyFYgLAAoAMLoqEAKY3sAESgBnGOhdRo1pSXV4CYhIqOGBbBgAiKBpbAA8AOgArFwjSVCgwe1DwqJiE5IjzKxt7CGwAFToYW184GBgwPgIoa2REuAA3OBdeBFgIAGpgdFxwW3NzOPckElxbVDhwCBIAbzMSEm66Kl4-WwheAAsACgRbAEcQWxcIAEpV9Y3Nl23d1GpebyoSAFl9w5GADl0BAAIJgMDoADutlwpwuVxu9zWTyeZwgIAQ3yotihJAAStd3FQXLZjgADP4QAG4EgAEhWZ0u1wg8TC1JGAF9giDNhDobD4uSADQPVGom4EEAuXwAFkEAFZhY9xSRDrY4HMEDKxaqnuDIVDfBEAOIAUXKEWVepInOt4s5tyIKttLuQyBIAHkqGA6CRzeUSEzERAXCQoZgANbhryHEjU1wkGAIdCxOjxF1QVAkeHMm5s-4jEgAQgYDBIpotEXu6Mx3ypNOBYP5MLhwZZTpdtaxewOJ3JhwgEBgMvdcVCDVs8V46GA5M7GztZk5RHMqmY6k02h4-CEomEEmkckURWsdgczjcHi8LSovn8mlIITCkXZmsCqT8GSyL4iZEhZCFJYZ6lBUVQ1Js9SNLwzStMk1gTGYKwRMAcDRAA+sMoyZBESi5HM+QpJya7rpugTbroe4GEexjMEAA)

* TypeScript

  ```ts
  export default {
    async fetch(request): Promise<Response> {
      async function MethodNotAllowed(request) {
        return new Response(`Method ${request.method} not allowed.`, {
          status: 405,
          headers: {
            Allow: "GET",
          },
        });
      }
      // Only GET requests work with this proxy.
      if (request.method !== "GET") return MethodNotAllowed(request);
      return fetch(`https://example.com`);
    },
  } satisfies ExportedHandler;
  ```

* Python

  ```py
  from workers import Response, fetch


  def on_fetch(request):
      def method_not_allowed(request):
          msg = f'Method {request.method} not allowed.'
          headers = {"Allow": "GET"}
          return Response(msg, headers=headers, status=405)


      # Only GET requests work with this proxy.
      if request.method != "GET":
          return method_not_allowed(request)


      return fetch("https://example.com")
  ```
