bridge: Migrating Nuxt 2 project to nuxt-bridge displays EventSource's response has a MIME type ("text/html") that is not "text/event-stream". Aborting the connection.

Environment


  • Operating System: Windows_NT
  • Node Version: v16.15.0
  • Nuxt Version: 2.16.0-27720022.54e852f
  • Nitro Version: 0.6.1
  • Package Manager: yarn@1.22.18
  • Builder: webpack
  • User Config: css, plugins, publicRuntimeConfig, buildModules, vuetify, build, serverHandlers, devServerHandlers, typescript, bridge
  • Runtime Modules: -
  • Build Modules: (), @nuxtjs/vuetify@1.12.3, @nuxt/bridge@0.10.1

Reproduction

The project below has the same issue, I suspect that it could be the nuxt.config file

reskit_UI

Describe the bug

Migrating Nuxt 2 project to nuxt-bridge displays:

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

image

Additional context

No response

Logs

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 20
  • Comments: 16

Most upvoted comments

Yes! I have a workaround that worked for me:

In the config of your nuxt.config.ts, add this:

  hooks: {
    ready(nuxt) {
      // https://github.com/nuxt/bridge/issues/607
      // translate nuxt 2 hook from @nuxt/webpack-edge to nuxt bridge hook
      nuxt.hook('server:devMiddleware' as any, async (devMiddleware: NodeMiddleware) => {
        await nuxt.callHook('server:devHandler', fromNodeMiddleware(devMiddleware));
      });
    },
  },

And import this in the same file:

import { fromNodeMiddleware, type NodeMiddleware } from 'h3';

Edit: sometimes, the application must be killed and restarted because it’s stucked (can’t refresh the page).

Same problem here