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

Creating Server Components Causes an Error #734

Open
Plinpod opened this issue Apr 11, 2024 · 1 comment
Open

Creating Server Components Causes an Error #734

Plinpod opened this issue Apr 11, 2024 · 1 comment
Labels
enhancement An improvement that needs to be added p2 Nice to have provider-authjs An issue with the authjs provider

Comments

@Plinpod
Copy link

Plinpod commented Apr 11, 2024

Environment

  • Operating System: Linux
  • Node Version: v18.18.2
  • Nuxt Version: 3.11.1
  • CLI Version: 3.11.1
  • Nitro Version: 2.9.6
  • Package Manager: [email protected]
  • Builder: -
  • User Config: modules, css, tailwindcss, runtimeConfig, app, image, routeRules, devtools
  • Runtime Modules: @pinia/[email protected], @sidebase/[email protected], @nuxtjs/[email protected],
  • Build Modules: -

Reproduction

  1. Install NuxtAuth
  2. Make a server component or page by appending server to the name Test.server.vue
  3. Refresh and find /api/auth/session 500 error

Describe the bug

When trying to create a server component or a NuxtIsland by adding server to a page or component
Test.server.vue

You get the following error on the server

Server Error [GET] "http://localhost/api/auth/session?callbackUrl=http:%2F%2Flocalhost%2F__nuxt_island%2FTest_zILZnACY7W.json": <no response> fetch failed

image

Additional context

No response

Logs

No response

@Plinpod Plinpod added bug A bug that needs to be resolved pending labels Apr 11, 2024
@zoey-kaiser
Copy link
Member

Hi @Plinpod 👋

We have not added support for Server components yet. I assume that we will need to add support for this by accessing the session via getServerSession. I assume the error you are experiencing is due to the component trying to access the client side session, which is not set on the server.

Due to this, I will categorize this as a feature request, rather than a bug. As mentioned above, I assume we will need to add a new composable that lets you access the server side session in server components.

I think adding support for this would be super cool, but also a bit tricky. Therefore, I will add this prioritize this feature a bit lower. As a workaround, could you try and categorize all authentication related logic inside the server component as a Client Component that does not get rendered on the server?

@zoey-kaiser zoey-kaiser added p2 Nice to have enhancement An improvement that needs to be added provider-authjs An issue with the authjs provider and removed bug A bug that needs to be resolved pending labels May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An improvement that needs to be added p2 Nice to have provider-authjs An issue with the authjs provider
Projects
None yet
Development

No branches or pull requests

2 participants