TrilonIO / aspnetcore-Vue-starter

*NEW* Asp.net Core & Vue.js (ES6) SPA Starter kit - Vuex, webpack, Web API, Docker, and more! By @TrilonIO
https://www.trilon.io
MIT License
1.22k stars 266 forks source link

EventSource's response has a MIME type ("text/html") that is not "text/event-stream". Aborting the connection. #97

Closed sksallaj82 closed 6 years ago

sksallaj82 commented 6 years ago

I finished this huge project based on this template, and I've been trying to deploy this to a production server, and I tried so many solutions online that I simply can not resolve the problem.

I have the following:

You are running Vue in development mode.
Make sure to turn on production mode when deploying for production.
See more tips at https://vuejs.org/guide/deployment.html

and the following error:

EventSource's response has a MIME type ("text/html") that is not "text/event-stream". Aborting the connection.

For some reason, the application believes its running on development mode, even though I set the following:

setx ASPNETCORE_ENVIRONMENT "Production" /M npm run build-vendor:prod

In startup.cs I added HotModuleReplacementEndpoint:

        if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
            app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions
            {
                HotModuleReplacement = true,
                HotModuleReplacementEndpoint = "/dist/__webpack_hmr"
            });
        }
        else
        {
            app.UseExceptionHandler("/Home/Error");
        }

When I see the network, I see a call coming from "dist/dist/__webpack_hmr"

In order to replicate this problem in Visual Studio, I right click on the project's property, go to Debug, and change ASPNETCORE_ENVIRONMENT : Developer to ASPNETCORE_ENVIRONMENT : Production.

So even though I changed the environment to production, something isn't right here.

So why does my environment still think I'm running in dev? This works perfectly fine in visual studios, but it blows up in IIS. I'm under a tight deadline, and I already lost a few nights over this.

sksallaj82 commented 6 years ago

well...

npm run build

fixed it...