Trouble trying to serve a file with a non text/html content type

I want to serve a js file, but have it parse velocity.

I have a template that is very short:
$response.addHeader(“Content-Type”, “text/javascript”)
$response.setContentType(“text/javascript”)
//Javascript file
#parseContainer(‘8382a988a9ad2cde7f1732ac1c20d4d1’,‘1746023283648’)

The container just puts out text. Chrome keeps telling me:
image
‘Refused to execute script from ‘https://revvable-prod.dotcms.cloud/revvabe-text.js’ because its MIME type (‘text/html’) is not executable, and strict MIME type checking is enabled.’

Yes, I am using htmlpageasset to ‘build’ the page. My understanding is that if I serve the file as file asset, it won’t parse Velocity. I know there’s some funky parts to outputting the header and response, so that’s why I am doing it first, in the template top.

Any hints, or perhaps a ‘that won’t work’? I’ve done it in the past with .svg files.

Mark,

I would try to turn off any page caching. I think using the page cache prevents any header manipulation. Also, I would suggest using the VTL/Scripting API to deliver things like this rather than a fake page. It was built for this.

Thanks for the hint!
I used the scripting API (dotCMS Github Repo) to successfully build a parseable js file that allows for velocity.
Needed to create a file get.vtl in the path /application/apivtl/text-widget/
$response.addHeader(“Content-Type”, “text/javascript”)
$response.setContentType(“text/javascript”)
function revtext(){ javascript here}

that creates a ‘view’ here:
https://demo.apex-prod.revvable.com/api/vtl/text-widget

Filename isn’t set a *.js but it appears to work fine. I think you can do some trickery with the respsonse header, but I don’t care.