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

Bug: 500 error on getKindeServerSession() in 2.3.7 #204

Open
4 tasks done
jonhester opened this issue Aug 28, 2024 · 14 comments
Open
4 tasks done

Bug: 500 error on getKindeServerSession() in 2.3.7 #204

jonhester opened this issue Aug 28, 2024 · 14 comments
Labels
bug Something isn't working
Milestone

Comments

@jonhester
Copy link

Prerequisites

Describe the issue

When trying to get user or isAuthenticated from getKindeServerSession() in client code I'm getting a 500 error on /api/auth/setup. There is nothing in the logs, even after setting the debug env variable. Downgrading to 2.3.6 fixes it. The 500 error means that I'm not able to see if a user is even authenticated from the browser.

This client example here will trigger the issue: https://docs.kinde.com/developer-tools/sdks/backend/nextjs-sdk/#protect-routes-with-kinde-auth-data

Library URL

https://github.com/kinde-oss/kinde-auth-nextjs

Library version

2.3.7

Operating system(s)

macOS

Operating system version(s)

macOS Sonoma 14.5

Further environment details

Next v13.4.3

Reproducible test case URL

No response

Additional information

No response

@jonhester jonhester added the bug Something isn't working label Aug 28, 2024
@diogopms
Copy link

I'm having the same issue..after upgrade (using Nextjs 14)

@DanielRivers
Copy link
Contributor

Thanks for raising, will get this checked out.

@peterphanouvong
Copy link
Collaborator

Looking into this

@peterphanouvong
Copy link
Collaborator

Thanks so much team, sorry about that bug! It should be fixed as a part of 2.3.8 #205

@QingjiaTsang
Copy link

QingjiaTsang commented Sep 29, 2024

Thanks so much team, sorry about that bug! It should be fixed as a part of 2.3.8 #205

The bug is still there, and I'm using v2.3.8 with nexts14. When it comes to desktop browsers, it's a bit acceptable, but as for mobile browsers like Chrome on iPhone, it will cause a breakdown of the page.

on the server:
image

on the client:
image

@Faschultes
Copy link

Faschultes commented Oct 12, 2024

Same issue here. I tried several versions. Now i went down to version 2.3.6. It works but i get the "401 Unauthorized" with loggedOut users which i guess was intended in this version.

@Ricardosgeral
Copy link

Ricardosgeral commented Oct 24, 2024

Same issue as @QingjiaTsang here. Any solution?
with these dependencies
"dependencies": {
"@kinde-oss/kinde-auth-nextjs": "^2.4.3",
"next": "14.2.16",
"next-themes": "^0.3.0",
"react": "18.3.1",
"react-dom": "18.3.1",
},

@DanielRivers
Copy link
Contributor

DanielRivers commented Oct 24, 2024

Am I right that this only occurs when there is no active session?

@Ricardosgeral
Copy link

Ricardosgeral commented Oct 24, 2024

@DanielRivers well i'm using it on the client

"use client";

import { cn } from "@/lib/utils";
import { useSelectedLayoutSegment } from "next/navigation";
import { useKindeBrowserClient } from "@kinde-oss/kinde-auth-nextjs";
import {
  RegisterLink,
  LoginLink,
} from "@kinde-oss/kinde-auth-nextjs/components";

interface NavProps {
  items?: {
    title: string;
    href: string;
    disabled?: boolean;
    external?: boolean;
  }[];
}

function SignInSignUpButtons() {
  return (
    <>
      <LoginLink
        postLoginRedirectURL="/dashboard"
        className={buttonVariants({ variant: "secondary" })}
      >
        Sign In
      </LoginLink>

      <RegisterLink
        postLoginRedirectURL="/dashboard"
        className={buttonVariants({ variant: "default" })}
      >
        Sign Up
      </RegisterLink>
    </>
  );
}

function AuthButtonsInner() {
  const { isAuthenticated } = useKindeBrowserClient();

  if (isAuthenticated) {
    return (
      <Link
        href="/dashboard"
        className={buttonVariants({ variant: "default" })}
      >
        Dashboard
      </Link>
    );
  } else {
    return <SignInSignUpButtons />;
  }
}

function AuthButtons() {
  return (
    <React.Suspense fallback={<SignInSignUpButtons />}>
      <AuthButtonsInner />
    </React.Suspense>
  );
}

@Parmesh-Yadav
Copy link

Hi,
any updates on this ?

@DanielRivers DanielRivers reopened this Nov 2, 2024
@soiloui
Copy link

soiloui commented Nov 20, 2024

I have the same problem, any news?

@rip32700
Copy link

rip32700 commented Dec 3, 2024

same problems..

@walhalla-software-dev
Copy link

walhalla-software-dev commented Dec 27, 2024

The problem still appears using the vanilla setup for nextjs in a fresh unmodified project... https://docs.kinde.com/developer-tools/sdks/backend/nextjs-sdk/

kinde setup: Email and Code

Environment: localhost:3000

Error:
✓ Compiled /api/auth/[kindeAuth] in 362ms (1121 modules) GET /api/auth/setup 500 in 565ms

dependencies:
"@kinde-oss/kinde-auth-nextjs": "^2.4.6", "next": "15.1.3", "react": "^19.0.0", "react-dom": "^19.0.0",

Any solutions or any working recommended setups to use kinde without errors from start?

@DanielRivers Yes, it happens only when there is no active session yet.

@kennethhaspeel
Copy link

kennethhaspeel commented Jan 11, 2025

Next 15.1.4
React 19

I'm using the isAuthenticated in a navbar to determine which menu items i want to show. If there is no logged in user i get the error mentioned above. After logging in, everything works fine. No previous login or after logout, the error pops up

I found this post in the Kinde community: https://community.kinde.com/nextjs-app-router-500-error-constant-setup-lJ0t6n4blKfx
It says to upgrade to a prelease (version 2.5.0-11).

But the error keeps on coming

@DanielRivers DanielRivers added this to the 2.5 milestone Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests