How to render a html page using cloudflare workers

I have created a route https://bewithrits.tech and when i am using https://bewithrits.tech/ then it will render the desired page but when i am adding https://bewithrits.tech/? or https://bewithrits.tech/?fb then it will give the error Error 1000
DNS pointed to prohibited IP wanted to implement in the given route not wanted to use
https://bewithrits.tech/* .
here is my tried code

const html1 = `

Document .button { background-color: rgba(162, 51, 79, 0.3); text-decoration: none; color: #a2334f; width: 150px; border: none; padding: 13px 26px; text-align: center; display: inline-block; font-weight: 600; font-size: 16px; line-height: 19px; margin: 4px 2px; cursor: pointer; opacity: 0.7; border-radius: 5px; } Know More `

const html2 = `

Document .button { background-color: rgba(162, 51, 79, 0.3); text-decoration: none; color: #a2334f; width: 150px; border: none; padding: 13px 26px; text-align: center; display: inline-block; font-weight: 600; font-size: 16px; line-height: 19px; margin: 4px 2px; cursor: pointer; opacity: 0.7; border-radius: 5px; } Know More
<p>queryy</p>
` addEventListener('fetch', (event) => { event.respondWith(handleRequest(event.request)) })

async function handleRequest(request) {
console.log(request.url)
console.log(request.url.includes(’/?’))

if(request.url===‘https://bewithrits.tech’ ||request.url===‘https://bewithrits.tech/’){
return new Response(html1, {
headers: {
‘content-type’: ‘text/html;charset=UTF-8’,
‘Access-Control-Allow-Origin’: ‘https://bewithrits.tech’,
‘Access-Control-Allow-Methods’: ‘OPTIONS, HEAD, POST, GET’,
‘Access-Control-Allow-Headers’:
‘X-Requested-With, Authorization,’ + ‘Content-Type, Accept’,
},
})

}

else if(request.url.includes(’/?’)){
return new Response(html2, {
headers: {
‘content-type’: ‘text/html;charset=UTF-8’,
‘Access-Control-Allow-Origin’: ‘https://bewithrits.tech’,
‘Access-Control-Allow-Methods’: ‘OPTIONS, HEAD, POST, GET’,
‘Access-Control-Allow-Headers’:
‘X-Requested-With, Authorization,’ + ‘Content-Type, Accept’,
},
})
}
}

You want to use Workers Sites to publish static web sites. It’s made for the purpose and uploading content with Wrangler is easier than trying to inline it with the JS code.
Start here:

actually, we are planning to use in this way because worker sites require bundled plan

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