This template code does not work on new google sites. It just keeps redirect to original google site domain name.
i think it sents
:authority:
http request header that might affect the outcome. how do i remove the authority header? can someone help? my “new google sites” already configured with domain name.
async function handleRequest(request) {
let url = new URL(request.url)
// Check if incoming hostname is
// a key in the ORIGINS object
let target = ORIGINS[url.hostname]
// If it is, proxy request to that third party origin
if (target) {
url.hostname = target
url.pathname = url.pathname;
return fetch(url, request)
}
// Otherwise, process request as normal
return fetch(request)
}
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
})
/**
* An object with different url's to fetch
* @param {Object} ORIGINS
*/
const ORIGINS = {
'example.com': 'www.moalboaladventures.com',
}