bridge icon indicating copy to clipboard operation
bridge copied to clipboard

_nuxt/empty.js was blocked with vite:true and ssr:false

Open HendrikJan opened this issue 2 years ago • 4 comments

Environment


  • Operating System: Linux
  • Node Version: v14.19.3
  • Nuxt Version: 2.16.0-27720022.54e852f
  • Nitro Version: 0.5.4
  • Package Manager: [email protected]
  • Builder: vite
  • User Config: bridge, ssr, serverHandlers, devServerHandlers, buildModules
  • Runtime Modules: -
  • Build Modules: (), @nuxt/[email protected]

Reproduction

  1. Open the default CodeSandbox template: https://codesandbox.io/p/github/nuxt/starter/tree/v2-bridge-codesandbox
  2. Replace nuxt.config.js with this:
import { defineNuxtConfig } from "@nuxt/bridge";

export default defineNuxtConfig({
  bridge: {
    vite: true
  },

  ssr: false
});

(or open this CodeSandbox where I already replaced the config: https://codesandbox.io/s/nuxt-bridge-vite-empty-error-ee3gjg?file=/nuxt.config.js)

  1. In Firefox, open the console (the error does not show in the sandbox console) and see the error:
Loading module from “https://ee3gjg.sse.codesandbox.io/_nuxt/empty.js” was blocked because of a disallowed MIME type (“text/html”).
Loading failed for the module with source “https://ee3gjg.sse.codesandbox.io/_nuxt/empty.js”.
  1. In Chrome open the console and see the error:
empty.js: Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec.
  1. See that the page does not load

Describe the bug

When using vite: true and ssr: false in Nuxt/bridge, the page does not load and in your browser console you find an error telling that the file empty.js was blocked because it has the wrong MIME-type.

Additional context

No response

Logs

No response

HendrikJan avatar Sep 29 '22 09:09 HendrikJan

đź‘Ť , facing the same issue

saideepesh000 avatar Oct 01 '22 12:10 saideepesh000

We are facing the same issue too.

smortexa avatar Oct 11 '22 08:10 smortexa

Facing the same issue.

mahsarajabpour avatar Oct 11 '22 08:10 mahsarajabpour

Facing the same issue.

zhancheng avatar Oct 13 '22 14:10 zhancheng

same here

yulafezmesi avatar Oct 24 '22 13:10 yulafezmesi

Same here, setting ssr:false gives this error.

ad-on-is avatar Nov 01 '22 09:11 ad-on-is

@danielroe Any ideas here? Happy to look into it otherwise

joel-wenzel avatar Dec 13 '22 22:12 joel-wenzel

Same issue here.

emretepedev avatar Dec 17 '22 15:12 emretepedev

Would welcome it, thank you @joel-wenzel 🙏

danielroe avatar Dec 19 '22 12:12 danielroe

I just ran into this same issue

JeffCharron avatar Jan 18 '23 20:01 JeffCharron

Does anybody know a workaround for this issue? Our "nuxi dev" gets slower and slower, so we would really like to use Vite soon.

HendrikJan avatar Jan 19 '23 15:01 HendrikJan

Why does nuxt bridge have this problem with ssr false? it is not suposed to work with ssg?

schirrel avatar Mar 16 '23 16:03 schirrel

Hello, everyone, who still waiting for the solution. I've found a workaround for this feature, because ssr: false, looks completely broken rn

We can overcome this by using Nitro routeRules

import { defineEventHandler } from 'h3'
import { defineNuxtConfig } from '@nuxt/bridge'

export default defineNuxtConfig({
  /* ... you old config */
  nitro: {
    routeRules: {
      '/*': { ssr: false }
    }
  },
  // ssr: false,
})

AndreyYolkin avatar Mar 26 '23 20:03 AndreyYolkin

I am also experiencing this. The workaround from @AndreyYolkin did not work for me.

JerryKusenberger avatar Apr 03 '23 20:04 JerryKusenberger

I am also experiencing this. The workaround from @AndreyYolkin did not work for me.

Do you have nitro enabled? And also: webpack or vite? Will try to help

AndreyYolkin avatar Apr 03 '23 21:04 AndreyYolkin

Yes I have nitro enabled. In my bridge options I set vite: true. Everything works if I set vite: false

JerryKusenberger avatar Apr 03 '23 23:04 JerryKusenberger

I just created an empty repo with just nuxt and nuxt bridge installed.

This is all that is in the nuxt config. If I set SSR to true the problem goes away.

import { defineNuxtConfig } from '@nuxt/bridge'

export default defineNuxtConfig({
  bridge: {
    nitro: true,
    vite: true, 
  },
 ssr: false,
})
`

JerryKusenberger avatar Apr 04 '23 00:04 JerryKusenberger

https://github.com/AndreyYolkin/nuxt-bridge-app-spa this seems to be ok (despite the ENOENT error, which I've already submitted as https://github.com/nuxt/bridge/issues/734)

AndreyYolkin avatar Apr 04 '23 10:04 AndreyYolkin

thanks @AndreyYolkin I'm one step closer. Now experiencing the same ENOENT issue.

JerryKusenberger avatar Apr 05 '23 15:04 JerryKusenberger

The issue has been resolved in https://github.com/nuxt/bridge/pull/775. cc: @danielroe

wattanx avatar May 17 '23 12:05 wattanx