loading a bundle.js file from webpack changes mime type to text/html

后端 未结 1 2050
执念已碎
执念已碎 2021-01-13 11:19

I am trying to achieve server side rendering for an app using react-redux and express for the server, webpack is being used to create the bundle.

I started off using

相关标签:
1条回答
  • 2021-01-13 11:19

    It seems to me as configuration issue.

    If it is returning MIME type ('text/html') that means, at that specific path it is not able to find/resolve the main.js file, so it is returning a default 404 html page instead, which is strictly defined to be javascript.

    So, Ideally what you can do is that you can configure your express server to serve static files as shown below.

    app.use(express.static(__dirname + "/static"));
    

    For more details, you can refer to::-> https://expressjs.com/en/starter/static-files.html

     

    Happy Coding!

    0 讨论(0)
提交回复
热议问题