Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
Ask Question
I have an existing SPA based on Asp .Net Core (I was using Yo generator-aspnetcore-spa to generate a template). It worked perfectly fine, but after migration to .NetCore 2.0 it started to throw the error:
EventSource's response has a MIME type ("text/html") that is not
"text/event-stream". Aborting the connection.
As I understood this problem affects only auto-refresh after updating any file (hot module replacement as far as I know). All other stuff is working fine.
So, the question is how to fix the error above?
I found the solution, mainly the problem is in .NetCore routing system, it is taking over and trying to handle the request, returning text/html, so it's sending the actual webpack_hmr hot file. To fix it you need to edit
Configure
method in the
Startup.cs
file.
Before:
// some code
app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions {
HotModuleReplacement = true
//some code
After:
// some code
app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions {
HotModuleReplacement = true,
HotModuleReplacementEndpoint = "/dist/__webpack_hmr"
// some code
The solution is taken from this thread on GitHub
Check whether your Hosting environment is set to Production or to Development (Webpack HMR is disabled for Production)
Change the Hosting environment to Development.
Add export ASPNETCORE_ENVIRONMENT=development to your ~/.bash_profile or ~/.zshrc file.
Follow the link for more exhaustive explanation.
Thus your output should be:
This link explains how to change the env in more depth.
–
–
–
–
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.