webpack-hot-middleware: Got error ---"EventSource's response has a MIME type ("text/html") that is not "text/event-stream". Aborting the connection."
Hi, I got the following error in browser when using this middleware, any idea what it mean?
EventSource's response has a MIME type ("text/html") that is not "text/event-stream". Aborting the connection.
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Reactions: 12
- Comments: 15
I also have this issue. My server setup looks like this:
EDIT:
I changed my config to this and it worked.
I had this error while serving a static index.html (using Express static middleware), and including my js bundle as a script there. As my first webpack entry, I had
'webpack-hot-middleware/client?path=http://localhost:3000/It started working when I changed it to
'webpack-hot-middleware/client?path=http://localhost:3000/__webpack_hmr',Yep, the
webpack-hot-middlewaremiddleware needs to come before the wildcard*handler so it can match the path.The
/__webpack_hmris aGETrequest, which means when you doapp.get('*'), then you send the HTML along withwebpack-hot-middleware. Fix it by adding route/__webpack_hmras an exception inapp.get('*').For me it is coming when I upgraded nuxt 2 to use nuxt-bridge
This request is firing again n again, resulting in the same error. Anyone can help?
application/json
On Mon, Jul 24, 2017 at 12:49 AM, Farah notifications@github.com wrote:
– Thank you for your time,
Shawn Simon McMaster Engineering iOS and Web Developer at Konrad Group
Instead of only returning, I needed to force the response type to “text/event-stream”:
Are you re-setting the
req.urlat any point? I was using theHtmlWebpackPluginto generate my index.html file which caused some issues with the webpack middleware. The suggested fix was to set thereq.urlto simply justreq.url = '/'when not one of my static or webpack middleware routes. One thing I also needed to do was to make sure i allow the url'/__webpack_hmr'to reach the webpack middleware as well so that socket can be established. I guess a hacky way would to do something like this:I would suggest something more eloquent but I am not really sure what your express app file looks like to suggest something better!