bridge icon indicating copy to clipboard operation
bridge copied to clipboard

Nuxt-bridge useNuxtApp() not available inside middleware

Open stephenjason89 opened this issue 2 years ago β€’ 15 comments

Environment



Reproduction

image

Describe the bug

useNuxtApp() inside a middleware fails with an error image

Additional context

No response

Logs

No response

stephenjason89 avatar Jul 21 '22 16:07 stephenjason89

Can you share minimal reproduction or middleware code?

antlionguard avatar Jul 22 '22 16:07 antlionguard

@antlionguard will provide one tomorrow. Is useNuxtApp working for you inside the middleware on nuxt-bridge?

stephenjason89 avatar Jul 23 '22 18:07 stephenjason89

@antlionguard will provide one tomorrow. Is useNuxtApp working for you inside the middleware on nuxt-bridge?

Yes it’s works at my project.

antlionguard avatar Jul 23 '22 18:07 antlionguard

Hello @antlionguard here is a repro https://github.com/stephenjason89/nuxt-bridge

Just visit index.vue and you'll see the error. image

middleware is defined inside the default.vue layout.

Please ignore the old comments about a different error. It was already resolved hehe.

Thanks

stephenjason89 avatar Jul 23 '22 18:07 stephenjason89

i think @danielroe should look at this

antlionguard avatar Jul 23 '22 19:07 antlionguard

Thank you @antlionguard & @danielroe

stephenjason89 avatar Jul 24 '22 07:07 stephenjason89

Seems to be working: https://stackblitz.com/github/stephenjason89/nuxt-bridge

danielroe avatar Jul 25 '22 12:07 danielroe

That's weird. I'll try again.

stephenjason89 avatar Jul 25 '22 17:07 stephenjason89

Hello @danielroe I have tried cloning the repo again, yarn install then yarn run dev but still getting the error.

Then i tried npm just like in stackblitz just to be sure. But still getting the error.

This is the line that throws the error image

stephenjason89 avatar Jul 25 '22 17:07 stephenjason89

Hello @danielroe I have tried cloning the repo again, yarn install then yarn run dev but still getting the error.

Then i tried npm just like in stackblitz just to be sure. But still getting the error.

This is the line that throws the error image

You should try remove yarn lock and install all packages again

antlionguard avatar Jul 25 '22 17:07 antlionguard

@antlionguard I just tried to remove yarn.lock now and yarn install. Same thing is happening for me.

here are the console errors image

@danielroe I know why the stackblitz is working. SSR is false on that project because there's no .env file. Setting SSR: true in nuxt.config.ts produces the error.

image

stephenjason89 avatar Jul 26 '22 05:07 stephenjason89

It feels like something broke somewhere, completely insignificant, and now it doesn't work 😞

Luferov avatar Aug 26 '22 18:08 Luferov

@Luferov yeah, let's wait and hope for a fix.

stephenjason89 avatar Aug 27 '22 14:08 stephenjason89

@danielroe I updated the reproduction to show the errors

I forgot to include my env file which makes my ssr variable true

so i just changed it here image

Latest nuxt-bridge causes more bugs. Every js seems to not work. It just renders the html

please see readme

stephenjason89 avatar Aug 27 '22 15:08 stephenjason89

@danielroe I updated the reproduction to show the errors

I forgot to include my env file which makes my ssr variable true

so i just changed it here image

Latest nuxt-bridge causes more bugs. Every js seems to not work. It just renders the html

please see readme

unfortunately if ssr: false then also doesn't work ☹️

Luferov avatar Sep 14 '22 19:09 Luferov

It has not responded for a while, so I am closing it. Reopen is welcome. (It would be helpful if you could provide a reproduction)

wattanx avatar Jan 06 '24 07:01 wattanx