* 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+CAngLzbPYZb6HbW5QDGU2AAwAWAMwA2AOwBWUZInTJALhYs2wDnC40+AkRJlyFkgLAAoAMLoqEAKY3sAESgBnGOhdRo1pSXV4CYhIqOGBbBgAiKBpbAA8AOgArFwjSVCgwe1DwqJiE5IjzKxt7CGwAFToYW184GBgwPgIoa2REuAA3OBdeBFgIAGpgdFxwW3NzOPckElxbVDhwCBIAbzMSEm66Kl4-WwheAAsACgRbAEcQWxcIAEpV9Y3Nl23d1GpebyoSAFl9w5GADl0BAAIJgMDoADutlwpwuVxu9zWTyeZwgIAQ3yotihJAAStd3FQXLZjgADP4QAG4EgAEhWZ0u1wg8TC1JGAF9giDNhDobD4uSADQPVGom4EEAuXzCQTSYWPcUkQ62OBzBAysXKp7gyFQ3wRADiAFFyhFFTqSJzLeLObciErrU7kMgSAB5KhgOgkU3lEhMxEQFwkKGYADWoa8hxI1NcJBgCHQsTo8SdUFQJHhzJubP+IxIAEIGAwSMazRF7ujMd8qTTgWD+TC4YGWQ6ndWsXsDidyYcIBAYDLXXFQg1bPFeOhgOT2xsbWZOURzKpmOpNNoePwhGIpLJ5OJFEVrHYHM43B4vC0qL5-JpSCEwpF2erAqk-Bksk+ImRIWRCpYJ6lBUVQ1Js9SNLwzStMk1gTGYKwRMAcDRAA+sMoyZBESi5HM+QpJyK6ruugSbroO4GPuxjMEAA)

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