Using worker to serve a website from custom domain - Issue

I’m trying to use Cloudflare worker to serve a website from my own domain, by following an article I found online.

The website is hosted by a 3rd party service, that I do not own. The article unfortunately is outdated with how Cloudflare looks and works, and I’m having issues.


I’ve followed the steps the best I could.

  1. Purchase domain through Cloudflare
  2. Create worker using my domain
  3. Create Worker Application
  4. Add custom domain
  5. Add worker to domain routes
  6. Add the supplied code (with url inserted)

The only step I did not follow from the article was adding DNS records, as you cannot add them for the domain when using worker proxied.

Any help would be appreciated.

FYI: I am not a developer.

Hi There

From what I understand, you want to return the content (body) of another page

Cloudflare allows you to test your code from their Playground:

But I think what you want is this:

 * @typedef {Object} Env

export default {
	 * @param {Request} request
	 * @param {Env} env
	 * @param {ExecutionContext} ctx
	 * @returns {Promise<Response>}
	async fetch(request, env, ctx) {

		//return fetch("");

		try {
			//Add the page to fetch
			const response = await fetch("");

			if (response.status == 200 && response.body != null) {
				// Handle successful response here
				return new Response(response.body);
			else {
				//See Logs in case there is no body in response
				return new Response("Response: " + response.statusText);


		} catch (error) {
			// Handle errors
			return new Response("Response: " + error);