nuxt / bridge

🌉 Experience Nuxt 3 features on existing Nuxt 2 projects
MIT License
273 stars 29 forks source link

Nuxt-Bridge RouteRules SSR settings not respected properly with nitro #1323

Closed kevcodez closed 1 month ago

kevcodez commented 1 month ago

Environment

Reproduction

Nuxt-Bridge Link: https://codesandbox.io/p/devbox/nuxt-bridge-forked-cp5gr5?workspaceId=30220bd5-c136-4f9b-95b9-4ccf2a841fd5

Nuxt 3 Link (this works as expected!): https://codesandbox.io/p/devbox/nuxt3-playground-forked-8rdmhh

Describe the bug

When using nested dynamic routes routes with nuxt-bridge + nitro and setting ssr: false in the routeRules, it seems like this is not properly respected. I managed to get the child page to only be rendered on the client, but the parent layout in the nested dynamic route would still be rendered on the server, causing rendering issues as my page does not support SSR.

I have attached a reproduction link for both Nuxt-Bridge and Nuxt 3 - with Nuxt 3 everything works as expected and the page is only rendered on the client. In the Nuxt-Bridge example, the page is still rendered on the server (you can see the console logs in the Nuxt terminal logging false for process.client that is logged within the pages indicating a server-side render.

I would expect nuxt-bridge with Nitro to behave the same and fully respect the ssr setting from the routeRules and render this entire page (parent nested page + child page) on the client-side.

Additional context

No response

Logs

No response

wattanx commented 1 month ago

Currently the bridge only supports nitro.routeRules instead of routeRules.

nitro: {
  routeRules: {
    "/test/**": { ssr: false },
    "/test": { ssr: false },
  },
},

This seems to be working. https://codesandbox.io/p/devbox/nuxt-bridge-forked-f47pjk

kevcodez commented 1 month ago

@wattanx you're a life saver, thanks!