๐ A simple and fast Cloudflare Worker that acts as a proxy โ bypass access restrictions and reach any website via your own custom Worker endpoint
This Worker takes any incoming request, changes the hostname to your desired target (like example.com), and forwards the request. It then returns the response from the target website. You can use it to send request to unaccessible websites, specially it is suitable for telegram bot (api.telegram.org)
- Go to Cloudflare Workers Dashboard
- Click "Create a Worker"
Copy and paste the following code into the Worker editor:
async function handleRequest(request) {
const url = new URL(request.url);
// Change the hostname to your target domain
url.hostname = 'myservice.com'; // โ Replace this with your desired domain
const newRequest = new Request(url.toString(), request);
try {
const response = await fetch(newRequest);
return response;
} catch (error) {
return new Response('Internal Server Error', {
status: 500,
headers: {
'content-type': 'text/plain',
},
});
}
}
addEventListener('fetch', (event) => {
event.respondWith(handleRequest(event.request));
});Replace 'myservice.com' in the code with the domain you want to proxy traffic to.
url.hostname = 'wikipedia.org';
Click โSave and Deployโ and Copy your Worker URL Use it instead of the your service url.
- This is a basic proxy. It doesnโt rewrite content or handle advanced request/response logic.
- No HTTPS validation or CORS headers are handled โ you can extend the code if needed.
- Use responsibly and respect the terms of service of any proxied websites.