How can I mask a url in cloudflare

how can i mask a url that is redirected to another domain

Unfortunately, you can’t.

More details here:

1 Like

You can use a worker.


Can anyone advise further on this worker scenario, trying a fetch worker, > just a static page, while keeping the url in the browser.

I used the sample:
Deployed this worker:

export default {
async fetch(request) {
const someHost = “``”;
const url = someHost + “/mybucket/image1.png”;

async function gatherResponse(response) {
const { headers } = response;
const contentType = headers.get(“content-type”) || “”;
if (contentType.includes(“application/json”)) {
return JSON.stringify(await response.json());
} else if (contentType.includes(“application/text”)) {
return response.text();
} else if (contentType.includes(“text/html”)) {
return response.text();
} else {
return response.text();

const init = {
headers: {
“content-type”: “text/html;charset=UTF-8”,

const response = await fetch(url, init);
const results = await gatherResponse(response);
return new Response(results, init);


I made a route rule sent to worker, and the only dns record I have is an A record > Proxied. But if I go to the site it gives a CF 522 time out error.

It looks like the problem is my contenttype is image/x-png … and I am not sure how to write the response code, it think it needs to be base64 encoded, but I am not a js developer so struggling a bit if anyone has any input.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.