* 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+CAngLzbPYZb6HbW5QDGU2AAwAmAIzCA7IMEA2UdIAsALhYs2wDnC40+AkeKmz5ghQFgAUAGF0VCAFNb2ACJQAzjHSuo0G0pLq8AmISKjhgOwYAIigaOwAPADoAK1dI0lQoMAcwiOjYxJTIi2tbBwhsABU6GDs-OBgYMD4CKBtkJLgANzhXXgRYCABqYHRccDsLC3iPJBJcO1Q4cAgSAG9zEhIeuipefzsIXgALAAoEOwBHEDtXCABKNY3NrdcdvdRqXh8qEgBZA6OowAcugIABBMBgdAAdzsuDOl2utwe62ez3OEBACB+VDs0JIACUbh4qK47CcAAb-CCA3AkAAkq3OVxuEAS4RpowAviFQVtITC4QkKQAaR5otG3AggVx+BSCACsIqeEpIRzscHmCFl4tVzwhUOhfkiAHEAKIVSLKvUkLnWiVcu5EFW2l3IZAkADyVDAdBI5oqJGZSIgrhI0MwAGtw94jiQaW4SDAEOg4nQEi6oKgSAiWbd2QDRiQAIQMBgkU0WyIPDFYn7U2kg8EC2Hw4Osp0u2vY-aHU4Uo4QCAwWXu+JhRp2BK8dDACmdzZ28xcogWVTMdSabQ8fhCMSSaRyRTFGz2RwudyebytKh+AKaUihcJRDmaoJpfyZbLPyJkKFkIorFPMpKmqWotgaJpeBaNoUhsSZzFWSJgDgGIAH0RjGLJIiUPJ5gKVIuTXddNyCbddD3AxD2MBRmCAA)

* 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")
  ```
