Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Server-side rendering with Nitro preset cloudflare_module and router.addRoute() not working #25428

Closed
nicgene opened this issue Jan 25, 2024 · 2 comments

Comments

@nicgene
Copy link

nicgene commented Jan 25, 2024

Environment

  • Operating System: Linux
  • Node Version: v18.18.0
  • Nuxt Version: 3.9.3
  • CLI Version: 3.10.0
  • Nitro Version: 2.8.1
  • Package Manager: yarn@1.22.19
  • Builder: -
  • User Config: devtools, pages
  • Runtime Modules: -
  • Build Modules: -

Reproduction

https://github.com/nicgene/nuxt-add-route/

Describe the bug

Hello, I'm deploying Nuxt 3 on Cloudflare Workers using the Nitro preset cloudflare_module. When adding routes from a plugin, the component isn't server-side rendered. I've attempted to reproduce this issue using the regular cloudflare preset, but I couldn't. Additionally, I've tried deploying to Netlify and Vercel without encountering the same problem. Therefore, I believe this issue is specific to the cloudflare_module preset.

// plugins/addRoute.ts
export default defineNuxtPlugin(async (nuxtApp) => {
  const router = useRouter();
  router.addRoute({
    name: "test",
    path: "/test",
    component: () => import("~/components/test.vue"),
  });
});

Additional context

Logs

No response

@danielroe
Copy link
Member

I think you likely need to do: component: () => import("~/components/test.vue").then(r => r.default || r)

@nicgene
Copy link
Author

nicgene commented Jan 29, 2024

That worked. Thank you very much!

@nicgene nicgene closed this as completed Jan 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants