---
title: Respond with another site · Cloudflare Workers docs
description: Respond to the Worker request with the response from another website (example.com in this example).
source_url:
  html: https://rest-api-guide.preview.developers.cloudflare.com/workers/examples/respond-with-another-site/index.md
  md: https://rest-api-guide.preview.developers.cloudflare.com/workers/examples/respond-with-another-site/
---

If you want to get started quickly, click on the button below.

[![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/cloudflare/docs-examples/tree/main/workers/respond-with-another-site)

This creates a repository in your GitHub account and deploys the application to Cloudflare Workers.

* 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+CAngLzbPYZb6HbW5QDGU2AAyCALAGYA7AA4ATFMEBOQVIBcLFm2Ac4XGnwHDx0uYuUBYAFABhdFQgBTO9gAiUAM4x0bqNFsqSmngExCRUcMD2DABEUDT2AB4AdABWblGkqFBgjuGRMXFJqVGWNnaOENgAKnQw9v5wMDBgfARQtsjJcABucG68CLAQANTA6Ljg9paWCZ5IJLj2qHDgECQA3hYkJL10VLwB9hC8ABYAFAj2AI4g9m4QAJTrm1vbbrv7qNS8vlQkALKHY5jABy6AgAEEwGB0AB3ey4c5XG53R4bF4vC4QEAIX5UewwkgAJVuniobnspwABgCIEDcCQACRrC7XW4QRIRWljAC+oTB2yhsPhiUpABonuj0XcCCA3P4RIIAKyi56SkjHexwBYIOUStUvSHQmH+KIAcQAopUoir9SRuTbJdz7kRVXbXchkCQAPJUMB0EgWyokFnIiBuEgwzAAawjPmOJFp7hIMAQ6HidESrqgqBIiNZdw5gLGJAAhAwGCQzZaoo9MdjfjS6aCIYK4QiQ2zna66ziDkczpTjhAIDA5R6EuEmvZErx0MBKV2tvaLNyiJZ1MxNNpdDx+EJRJJZPIlFISrYHE5XB4vD42lR-IFtKQwhFopytcF0gEsjlX1EyNCZDFNY57lFUNR1NsjTNLwrTtKkthTBYaxRMAcCxAA+qM4zZFEKj5AshRpNy64bluwQ7vo+5GEephSMwQA)

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