I am getting following error while rendering (using sendFile) an html file containing line <script src="…/…/viewer/krpano.js"> to a browser from a node-js server. I even tried to define the Content-Type=“text/javascript” in the above <script> line of the HTML page.
The resource from “http://localhost:3000/viewer/krpano.js” was blocked due to MIME type (“text/html”) mismatch (X-Content-Type-Options: nosniff).
Loading failed for the with source “http://localhost:3000/viewer/krpano.js”.
Does anyone have an idea how to enable inclusion of src file in the HTML files rendered from nodejs? Google search didn’t help me so far. This is required for my third party module AR-SCADA.
Make sure the your web server which is serving up your javascript resource includes the correct mime type in the Content-type header (should be text/javascript
, not text/html
)
Thanks for your reply. However I figured out the problem. Its not what you wrote (I had already tried it). The problem is NodeJS doesn’t render HTML pages like other servers do, we have to specify the path for static files (such as JS, CSS, iamges etc) in the server code, then send the html file to client. Then it works fine! For inline JS code embedded in HTML page its work just fine, that’s why I hadn’t realized this earlier. Now its running fine. I will soon release a new version of my AR-SCADA module which will run on NodeJS server, connected back to back with Ignition server!
Thanks a lot for your help.
Best