* 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+CAngLzbPYZb6HbW5QDGU2AAzCAbCICMAdnEAOAExyZALhYs2wDnC40+A4YLFTZCmQFgAUAGF0VCAFNb2ACJQAzjHSuo0G0pLq8AmISKjhgOwYAIigaOwAPADoAK1dI0lQoMAcwiOjYxJTIi2tbBwhsABU6GDs-OBgYMD4CKBtkJLgANzhXXgRYCABqYHRccDsLC3iPJBJcO1Q4cAgSAG9zEhIeuipefzsIXgALAAoEOwBHEDtXCABKNY3NrdcdvdRqXh8qEgBZA6OowAcugIABBMBgdAAdzsuDOl2utwe62ez3OEBACB+VDs0JIACUbh4qK47CcAAb-CCA3AkAAkq3OVxuEAS4RpowAviFQVtITC4QkKQAaR5otG3AggVx+AAsggArCKnhKSEc7HB5ghZeK1c8IVDoX5IgBxACiFUiKv1JC5NolXLuRFVdtdyGQJAA8lQwHQSBaKiRmUiIK4SNDMABrCPeI4kGluEgwBDoOJ0BKuqCoEgIlm3dkA0YkACEDAYJDNlsiDwxWJ+1NpIPBAth8JDrOdrrr2P2h1OFKOEAgMFlHviYUadgSvHQwApXc29vMXKIFlUzHUmm0PH4QlEEmk8kUxRs9kcLncnm8rSofgCmlIoXCUQ5WqCaX8mWyL8iZChZBFFYZ5lJU1S1FsDRNLwLRtCkNiTOYqyRMAcAxAA+iMYxZJESh5PMBSpFy64bluQQ7ro+4GIexiKMwQA)

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