Javascript .mjs extension for module script includes has wrong mime type

Using Wrangler (v2) to publish a Nuxt 3 app with server-side rendering as a Workers Site.

The wrangler publish command works and the site HTML loads but it has a include of type module pointing to an extension .mjs, however browsers are not loading this script file because Cloudflare is responding with a text/html mime type.

Have you tried with Cloudflare Pages instead of Workers Sites?

Pages would probably be the easiest solution here as @adaptive suggested, but if you don’t want to use Pages…

Is the .mjs file actually returning the code as you expect, just with a bad mime type? Or is it returning something else?

Can you share your Workers Sites code?

If it’s just a mime type issue, you could fix it with something like this (pseudo-code):

if(/\.mjs$/.test(url.pathname){
    // fetch asset
    // set response headers
    response.headers.set('content-type', 'application/javascript');
}
// other code
return response;

Cloudflare Pages doesn’t support server-side rendering - and the /functions folder integration isn’t supported for full-site serving (or at all) with any framework I know of.