Redirect Traffic

Hi, We are trying to set up the following traffic pattern:
-all requests for www.site/blog{/}* are sent to the existing A record
-all requests for www.site{/path} are sent to https://site.webflow.io/{path}

I’ve written the following code. The blog loads correctly, but the Webflow site does not. What is wrong?

addEventListener(‘fetch’, event => {
event.respondWith(fetchBlog(event.request))
})
async function fetchBlog(request) {
const reqUrl = new URL(request.url)
if (reqUrl.pathname.startsWith(‘/blog’)) {
// Return response unmodified.
console.log(reqUrl.href)
return fetch(reqUrl, request)
} else {
let newUrl = new URL(‘https://site.webflow.io/’)
newUrl.pathname = reqUrl.pathname
console.log(newUrl.href)

	return fetch(newUrl, { 
		method: request.method, 
	headers: request.headers 
	}) 
	//return fetch (newUrl, request) 
} 

}

Hi!
Sorry this post was 2 years ago, but i’m having the same issue but with cname records.
This is the schematic.
example.com/blob/path/to/file
into
2ndexample.com/path/to/file

I want the code to change the first url then make a cname request.
I’m a beginner and i’m a bit stupid. Did you end up fixing it?

Oh just letting you know,
my past experiences with webflow demonstrated to me that sites created on the platform hate redirects in iframes. They’ll just blank out the window.