Content-type of Cloudflare Workers set always to text/html, probably shouldn't?


#1

I have a fairly simple worker set up to forward calls to Azure static web sites. In essence:

addEventListener('fetch', event => {
    event.respondWith(fetchAndTransform(event.request))
})

async function fetchAndTransform(request) {  		
    let src = new URL(request.url)
    let dst = new URL('https://storagesomething.zonesomething.web.core.windows.net')
    dst.pathname += src.pathname    
   		
    let response = await fetch(dst, request);
    const content_type = response.headers.get("Content-Type");
    console.log('Content-Type: ' + content_type);   

    return response;
}

#2

Sorry, the message was sent while I was editing and it appears I cannot edit the body. The issue is that in the worker editing console window the site shows normally as should, but not anymore in a browser. In the editing console window the Content-Type header is set as should, but for the browser it’s always text/html and I don’t seem to understand why is that. I have cleared the cache (and set development mode on), cleared browser cache etc., but nothing seems to help.

Is there something obvious that I don’t understand? It appears I can set new headers and they show in the output.


#3

Problem solved! In the routing the rule should be ending at /* to apply to all routes.