Can cloudflare domain workers have free SSL ?

Ive made a worker with following index.js
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request));
});

async function handleRequest(request) {
const response = new Response('helloWorld', {
headers: {
'Content-Type': 'text/plain',
'Access-Control-Allow-Origin': '*', // Replace with your allowed origins
'Access-Control-Allow-Methods': 'GET, POST, OPTIONS', // Allow the necessary methods
},
});
return response;
}
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request));
});

async function handleRequest(request) {
const response = new Response('helloWorld', {
headers: {
'Content-Type': 'text/plain',
'Access-Control-Allow-Origin': '*', // Replace with your allowed origins
'Access-Control-Allow-Methods': 'GET, POST, OPTIONS', // Allow the necessary methods
},
});
return response;
}
but I couldn't fetch it from a serverless front end html like
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Cloudflare API Request</title>
</head>
<body>
<button id="fetchButton">Fetch Data</button>
<p id="responseText"></p>
<script>
const fetchButton = document.getElementById('fetchButton');
const responseText = document.getElementById('responseText');

fetchButton.addEventListener('click', async () => {
try {
const response = await fetch('https://hyperbeam.nithinsteven32.workers.dev/');
if (!response.ok) {
throw new Error('Network response was not ok');
}
const data = await response.text();
responseText.textContent = data;
} catch (error) {
console.error('Error fetching data:', error);
responseText.textContent = 'Error fetching data';
}
});
</script>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Cloudflare API Request</title>
</head>
<body>
<button id="fetchButton">Fetch Data</button>
<p id="responseText"></p>
<script>
const fetchButton = document.getElementById('fetchButton');
const responseText = document.getElementById('responseText');

fetchButton.addEventListener('click', async () => {
try {
const response = await fetch('https://hyperbeam.nithinsteven32.workers.dev/');
if (!response.ok) {
throw new Error('Network response was not ok');
}
const data = await response.text();
responseText.textContent = data;
} catch (error) {
console.error('Error fetching data:', error);
responseText.textContent = 'Error fetching data';
}
});
</script>
</body>
</html>
when i tried https://checkforcloudflare.selesti.com/?q=https://hyperbeam.nithinsteven32.workers.dev/ I learned ssl was not setup on the url maybe that's the issue ? Any help appreciated 😊
Check for Cloudflare
Check for Cloudflare® - by Selesti Ltd
Quickly and easily check to see if your or any other domain is using Cloudflare!
1 Reply
Chaika
Chaika•16mo ago
Workers have ssl built in yea, that tester is just outdated and assuming that Cloudflare uses a specific certificate chain that they no longer use. You can open it in your browser and see it has SSL. Most likely you're getting a CORS error or something along the lines, from your page with that html open up console (ctrl+shift+i -> click console), click the button and look for errors
Want results from more Discord servers?
Add your server