admin管理员组文章数量:1401673
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 the following documentation:
.html
I have the following set up to load up the main.js created from webpack:
<script type="application/javascript" src="/static/main.js"></script>
On firing up the express server though, this is what I see in the console:
Refused to execute script from 'http://localhost:8080/static/main.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
This is not firing up in any browser. Any idea what might be going on?
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 the following documentation:
https://redux.js/docs/recipes/ServerRendering.html
I have the following set up to load up the main.js created from webpack:
<script type="application/javascript" src="/static/main.js"></script>
On firing up the express server though, this is what I see in the console:
Refused to execute script from 'http://localhost:8080/static/main.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
This is not firing up in any browser. Any idea what might be going on?
Share Improve this question edited Jan 8, 2018 at 20:51 pj013 asked Jan 8, 2018 at 20:31 pj013pj013 1,4291 gold badge12 silver badges31 bronze badges 1- Does the file exists at the location(localhost:8080/static/main.js)? – Brick Yang Commented May 8, 2018 at 13:54
1 Answer
Reset to default 5It 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./en/starter/static-files.html
Happy Coding!
本文标签: javascriptloading a bundlejs file from webpack changes mime type to texthtmlStack Overflow
版权声明:本文标题:javascript - loading a bundle.js file from webpack changes mime type to texthtml - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744291661a2599142.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论