Giter VIP home page Giter VIP logo

kinde-auth-nextjs's People

Contributors

arden144 avatar coel avatar danielrivers avatar daveordead avatar dependabot[bot] avatar evgenyk avatar joeldebont avatar kengreeff avatar kinde-engineering avatar marcosmartini avatar nip10 avatar oliwolff1 avatar peterphanouvong avatar seagull29 avatar snyk-bot avatar twestos avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

kinde-auth-nextjs's Issues

Bug: middleware with withAuth does not work: TypeError: Cannot read properties of undefined (reading 'value')

Prerequisites

Describe the issue

A simple app with one protected page using middleware does not work

import { withAuth } from "@kinde-oss/kinde-auth-nextjs/middleware";

export default withAuth(async function middleware(req) {
  console.log("look at me", req.kindeAuth);
});

export const config = {
  matcher: ["/admin"],
};

however, when doing this, it works

import { withAuth } from "@kinde-oss/kinde-auth-nextjs/middleware";
export default function middleware(req) {
  return withAuth(req);
}
export const config = {
  matcher: ["/admin"],
};

This is the error I'm getting
image

I don't have any special setup in-place. Just a public page with a <Link> to a protected page.

Library URL

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

Library version

2.2.4

Operating system(s)

macOS

Operating system version(s)

14.4.1

Further environment details

No response

Reproducible test case URL

No response

Additional information

No response

middleware publicPaths is not configurable, middleware always does an auth check

Prerequisites

Describe the issue

We're missing the ability to set public paths for the middleware to ignore.

According to next.js design, multiple middleware are meant to be chained/nested, however currently adding the Kinde middleware to a next.js project will trigger auth check on all paths whenever middleware runs (per matcher: setting)

Because most projects have protected and public paths, we desperately need a way to set public paths for Kinde to ignore auth for - i.e. the req.kindeAuth would be optional, but lack of cookie or invalid token must not cause a redirect to login page. matcher is not the way to do it, because the project might have other chained middleware that DO want to run on those paths (in other words, matcher disables/enables all middleware, while we need to prevent just Kinde redirect in certain paths).

Here's the hard-coded value: https://github.com/kinde-oss/kinde-auth-nextjs/blob/main/src/authMiddleware/authMiddleware.js#L39

Here's how clerk middleware exposes this in publicPaths: https://clerk.com/docs/references/nextjs/auth-middleware#options

Library URL

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

Library version

2.1.15

Operating system(s)

macOS

Operating system version(s)

n/a

Further environment details

next.js 14.1.3

Reproducible test case URL

No response

Additional information

No response

Bug: Module not found: Cant resolve fs

Prerequisites

Describe the issue

Hey team, running into this issue when using the included auth button components in a client component: Module not found: Can't resolve 'fs'

There's a good comment in the nextjs repo about the issue and an optimal solution from this package here vercel/next.js#54220 (comment). Would be great if we could apply the solution here so that the components can be easily consumed in client components 🙌

Library URL

https://github.com/kinde-oss/kinde-auth-react”

Library version

1.8.12

Operating system(s)

Windows

Operating system version(s)

Ventura 13.2

Further environment details

No response

Reproducible test case URL

No response

Additional information

No response

Bug: Error 500 on production

Prerequisites

Describe the issue

I launched my product with kinde's auth here: https://the-abc.tech
I did most of the things correctly.

Library URL

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

Library version

2.2.5

Operating system(s)

macOS

Operating system version(s)

14.4.1

Further environment details

No response

Reproducible test case URL

https://the-abc.tech

Additional information

No response

Feature request: (Unable to Create JWT Claims and Integrate with Hasura in Kinde Auth Application)

Prerequisites

What is the problem you’re trying to solve?

Hello,I am currently working on integrating Hasura with the Kinde Auth application. I'm facing an issue with creating JWT claims and adding them to the token. Here are the steps I've attempted, but encountered difficulties:

What solution would you like to see?

I've been trying to generate JWT claims for the integration.I need guidance on how to properly add these claims to the token for seamless integration with Hasura.Could someone provide guidance or a step-by-step tutorial on how to achieve this integration between Kinde Auth and Hasura?Thank you in advance for your help.

Additional information

No response

Bug: Middleware Authentication Fails When `postLogoutRedirectURL` is Undefined

Prerequisites

Description:

There's an edge-case bug in the authMiddleware found in src/authMiddleware/authMiddleware.js where the middleware authentication fails with a TypeError if the postLogoutRedirectURL environment variable is not set. This results from the trimTrailingSlash function being called with an undefined value.

Happy to do any of the suggested fixes, just wanted to check before submitting. Or we could just close with RTFM of setting the value of course (I was testing and took it out)

Steps to Reproduce:

  1. Ensure the postLogoutRedirectURL environment variable is not set.
  2. Run the application and trigger the authMiddleware by browsing to a directory that encompassed by the matcher

Expected Behaviour:

The middleware should handle the absence of postLogoutRedirectURL gracefully, either by falling back to a default value or by providing a clear error message indicating that the postLogoutRedirectURL configuration is missing.

Actual Behavior:

A TypeError: Cannot read properties of undefined (reading 'charAt') error is thrown, stemming from the trimTrailingSlash function.

Suggested Fix:

There are several ways to address this issue:

  1. Input Validation:

    • Perform a check for undefined before calling trimTrailingSlash.
    const logoutUrl = config.postLogoutRedirectURL ? trimTrailingSlash(config.postLogoutRedirectURL) : undefined;
  2. Configuration Validation:
    Fail the configuration load if postLogoutRedirectURL is not set, providing a clear error message to the developer.

  3. Default Value: Provide a default value for postLogoutRedirectURL in case it's not set.

  4. Error Handling: Enhance error handling within trimTrailingSlash to cope with undefined inputs gracefully.

Library URL

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

Library version

1.8.21

Operating system(s)

macOS

Operating system version(s)

Mac OS 14.0

Further environment details

No response

Reproducible test case URL

No response

Additional information

No response

Bug: No support for expired sessions

Prerequisites

Describe the issue

The issue

Neither AuthProvider nor KindeBrowserClient respect the token expiry times and don't handle expired sessions and re-authentication. There is no mention of expiration handling anywhere in docs. Nothing in source code.

After the token expires, if the app is still open and tries to fetch data (as most RIA apps do) everything will start failing - i.e. with 405 as described in #171 or plain 403 401.

Expected

All other auth sdks I know provide implicit or explicit expiration handling - usually by checking the exp claim and making sure that before it expires (with some buffer), token is regenerated or redirection happens to auth page/route to prevent errors.

Library URL

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

Library version

2.2.10

Operating system(s)

macOS

Operating system version(s)

23E224

Further environment details

No response

Reproducible test case URL

No response

Additional information

No response

Bug: Property 'login' does not exist on type 'KindeState'

Prerequisites

Describe the issue

I am trying to setup a custom login page as described in the documentation with Nextjs

`import { useKindeAuth } from '@kinde-oss/kinde-auth-nextjs';

function SignInButton() {
const { login } = useKindeAuth();

return (
    <button onClick={() => login({
        authUrlParams: {
            connection_id: "conn_e5f80aa5258e4685bf629b38003ee954",
            login_hint: "[email protected]"
        }
    })}>
        Sign in with email
    </button>
);

}`

But i keep getting the error response

Property 'login' does not exist on type 'KindeState'.

at the point where i try importing the login method.

Library URL

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

Library version

2.2.3

Operating system(s)

Windows

Operating system version(s)

Ubuntu linux

Further environment details

No response

Reproducible test case URL

No response

Additional information

No response

Bug: Error: Cannot get user details, no authentication credential found

Prerequisites

Describe the issue

"use client";
import { useKindeBrowserClient } from "@kinde-oss/kinde-auth-nextjs";

export function Page() {
  const {
    isLoading,
    isAuthenticated,
  } = useKindeBrowserClient();

  return <div>{isAuthenticated}</div>
}

Every time the component is rendered, and the user is not currently logged in, it spams this error into our platform error logs:

Error: Cannot get user details, no authentication credential found
    at eval (webpack-internal:///(rsc)/./node_modules/@kinde-oss/kinde-typescript-sdk/dist/sdk/clients/server/authorization-code.js:166:31)
    at step (webpack-internal:///(rsc)/./node_modules/@kinde-oss/kinde-typescript-sdk/dist/sdk/clients/server/authorization-code.js:50:23)
    at Object.eval [as next] (webpack-internal:///(rsc)/./node_modules/@kinde-oss/kinde-typescript-sdk/dist/sdk/clients/server/authorization-code.js:31:53)
    at fulfilled (webpack-internal:///(rsc)/./node_modules/@kinde-oss/kinde-typescript-sdk/dist/sdk/clients/server/authorization-code.js:22:58)

Library URL

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

Library version

2.2.3

Operating system(s)

macOS

Operating system version(s)

n/a

Further environment details

Next.js 14.2.2

Reproducible test case URL

No response

Additional information

No response

Bug: (Error when i click sign in)

Prerequisites

Describe the issue

getting this
The specified organization could not be found.

Library URL

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

Library version

3.0.15

Operating system(s)

macOS

Operating system version(s)

macOS Catalina 10.15.7

Further environment details

No response

Reproducible test case URL

No response

Additional information

No response

Bug: post_logout_redirect_url after /api/auth/logout does not redirect to specified url

Prerequisites

Describe the issue

When loging a user out via the /api/auth/logout?post_logout_redirect_url=/login?type=bewerben url it redirects me to my POST_LOGOUT_REDIRECT_URL I have set in my .env in this case /login without the additional params. I also changed this in the env to be /dashboard and as expected I get forwarded to /dashboard instead of /login?type=bewerben.

Library URL

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

Library version

2.1.15

Operating system(s)

Windows

Operating system version(s)

11 Version 23H2 (Build 22631.3155)

Further environment details

Node: v18.18.2
NextJS: 13.4.19

Reproducible test case URL

No response

Additional information

No response

Documentation issue: Add link to starter kit

Prerequisites

How can we improve the docs or what is missing?

According to the following Kinde OSS template, there should be a link to the related starter kit (if it exists): https://github.com/kinde-oss/kinde-oss-repo-template/blob/main/README_template_non-generator.md

Provide extra context, such as what you were trying to do and your requirements

N/A

If the docs page already exists, please provide a link

No response

Bug: Cannot find module '@kinde-oss/kinde-auth-nextjs/components' or its corresponding type declarations

Prerequisites

Describe the issue

I used the document at https://kinde.com/docs/developer-tools/nextjs-sdk/ to set up my next.js project. However, I encountered a typescript issue mentioned in the title.

Library URL

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

Library version

1.9.1

Operating system(s)

macOS

Operating system version(s)

macOS 14.1.2 Chrome Version 121.0.6167.139

Further environment details

No response

Reproducible test case URL

No response

Additional information

No response

Cookies error in Next.js Edge

Prerequisites

Describe the issue

When I use Edge functions with the last version of library, an error appears Error [TypeError]: Native module not found: cookie.

export const runtime = 'edge';
export async function POST(req:NextRequest){
    const {getUser} = getKindeServerSession()
    const user = await getUser()
}

This code you can see here doesnt works and generate the problem, but when you set this api route as no edge function it gives the error descriped

Library URL

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

Library version

"@kinde-oss/kinde-auth-nextjs": "^2.0.4",

Operating system(s)

Windows

Operating system version(s)

Windows 11

Further environment details

No response

Reproducible test case URL

No response

Additional information

No response

Feature request: NextJS SDK work with Node v18

Prerequisites

What is the problem you’re trying to solve?

I was able to get setup with the NextJS SDK by downgrading to my Node version to 16.20.2

I would expect the Kinde NextJS SDK to work with Node v18

What solution would you like to see?

I would like to see the Kinde NextJS SDK work with v18

Additional information

No response

Feature request: text-align-center on Kinde pages?

Prerequisites

What is the problem you’re trying to solve?

The alignment of the title's text can be so off depending on its length...

What solution would you like to see?

Please provide an input to change it just like we can change the alignment of the whole component relative to the page.

Additional information

image

Documentation issue: chaining middleware with next

Prerequisites

How can we improve the docs or what is missing?

I'm setting up Kinde for the first time and I need to have a few other middleware along with the include authMiddleware. I've looked through docs and other areas and can't find an example on how to do this.

I've done this setup before following https://reacthustle.com/blog/how-to-chain-multiple-middleware-functions-in-nextjs as an example how to chain middleware but when I do this option I get an error back from the authMiddleware.

Is there any guidance that could be given? It should would be handy to have an example in the documentation.

Provide extra context, such as what you were trying to do and your requirements

Trying to use multiple middleware in NextJS

If the docs page already exists, please provide a link

No response

Getting 500 response after login redirect

Prerequisites

Describe the issue

I am getting 500 error during redirect to /api/auth/kinde_callback

CleanShot 2024-05-28 at 11  36 19@2x

CleanShot 2024-05-28 at 11  37 17@2x

Library URL

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

Library version

^2.2.11

Operating system(s)

macOS

Operating system version(s)

14.5 (23F79)

Further environment details

No response

Reproducible test case URL

https://github.com/kingRayhan/kinde-play

Additional information

No response

Bug: NextJS App router - Authentication error

Prerequisites

Describe the issue

I followed the guide here:
https://kinde.com/docs/developer-tools/nextjs-sdk/

When I create a Link component and send the user to /api/auth/login, the user is able to request a OTP, but the response once they input the OTP is:
Authentication error
URL: https://mysite.kinde.com/auth/cx/_:nav&m:auth_error

The web console does not show any information regarding this error.

I am able to use the import {RegisterLink, LoginLink} from "@kinde-oss/kinde-auth-nextjs/server";
without issue.

I tried creating both server and client components

Library URL

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

Library version

1.8.16

Operating system(s)

Other Linux

Operating system version(s)

Fedora 38

Further environment details

Node version: 20.5.1

Reproducible test case URL

No response

Additional information

No response

Bug: getKindeServerSession on a api route not working

Prerequisites

Describe the issue

I have a user logged in a local environment (me) sending a request to a api route, but, even when im logged in, and passing the request & response instances, the getKindeServerSession(request, response) is returning false.

Code:

import { getKindeServerSession } from "@kinde-oss/kinde-auth-nextjs/server";

export async function GET(request: Request, res: Response) {
    const {isAuthenticated} = getKindeServerSession();
    console.log(await isAuthenticated())
    return Response.json({ Ola: true })
}

Library URL

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

Library version

2.0.6

Operating system(s)

Windows

Operating system version(s)

11

Further environment details

No response

Reproducible test case URL

No response

Additional information

No response

Bug: user cookie is not set properly on callback, causing error on middleware

Prerequisites

Describe the issue

After redirect back to Nextjs page, it seems that user cookie is not set. User cookie is expected in authMiddleware

  if (isAuthorized && onSuccess) {
    return await onSuccess({
      token: accessTokenValue,
      user: JSON.parse(req.cookies.get('user').value)
    });
  }

Because user cookie is not present, this is throwing reading from undefined error.
image

I found this, by removing all cookies and site data and refreshing the page. I've checked my setup and it's same as in the guide.

export default withAuth(async function middleware(request: NextRequest) {
  const pathname = request.nextUrl.pathname;
  // Home page does not need any special protection
  if (
    !pathname ||
    pathname === "" ||
    pathname === "/" ||
    pathname.startsWith("/new")
  )
    return;
import { handleAuth } from "@kinde-oss/kinde-auth-nextjs/server";

export const GET = handleAuth();

I'm not sure why it occurred right now, I tested with previous version of library and same issue is happening. My wild guess is that maybe it's not about the library but something else has changed?

Library URL

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

Library version

2.2.4

Operating system(s)

macOS

Operating system version(s)

Sonoma 14.4.1

Further environment details

Newest version of Nextjs, Web browser: Newest Firefox, tested with github auth and email/password login

Reproducible test case URL

No response

Additional information

No response

Bug: organization, getOrganization returning string instead of KindeOrganization

Prerequisites

Describe the issue

The TS types are lying:

export type KindeOrganization = {
  orgCode: string | null;
};
export type KindeState = {
  organization: KindeOrganization;
  getOrganization: () => KindeOrganization;
  getUserOrganizations: () => KindeOrganizations | null;
};

but when running the code I'm getting:
image

Library URL

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

Library version

2.2.3

Operating system(s)

macOS

Operating system version(s)

n/a

Further environment details

Next.js 14.2.2

Reproducible test case URL

No response

Additional information

No response

Documentation issue: (How to get specific user roles by their id)

Prerequisites

How can we improve the docs or what is missing?

I am using Kinde with a Next.js application. In my business login, I would like to retrieve user roles based on the user's ID. I am currently using the "createKindeManagementAPIClient" but it doesn't have a method to fetch the specific user roles. Furthermore, the access_token does not contain the roles information. Could you kindly assist me in retrieving the roles of a specific user?
Thanks.

Provide extra context, such as what you were trying to do and your requirements

I am using Kinde with a Next.js application. In my business login, I would like to retrieve user roles based on the user's ID. I am currently using the "createKindeManagementAPIClient" but it doesn't have a method to fetch the specific user roles. Furthermore, the access_token does not contain the roles information. Could you kindly assist me in retrieving the roles of a specific user?
codes:

const enforceUserIsAuthenticated = t.middleware(async ({ ctx, next }) => {
  const {usersApi, rolesApi} = await createKindeManagementAPIClient();

  
  const { isAuthenticated, email, userId } = ctx.session!;

  console.log("[protected Procedure", await usersApi.getUsers({userId}));
  console.log("[protected Procedure", await rolesApi.getRoles({
  }));


  if (!isAuthenticated || !email || !userId) {
    throw new TRPCError({ code: "UNAUTHORIZED" });
  }
  return next({
    ctx,
  });
});

If the docs page already exists, please provide a link

No response

Bug: Type error on build

Prerequisites

Describe the issue

Hi,

when i try to run pnpm build this type error occurs:

.next/types/app/api/auth/[kindeAuth]/route.ts:59:7:

Type error: Type '{ __tag__: "GET"; __return_type__: Promise<(req: any, res: any) => any>; }' does not satisfy the constraint '{ __tag__: "GET"; __return_type__: void | Response | Promise<void | Response>; }'.
  Types of property '__return_type__' are incompatible.
    Type 'Promise<(req: any, res: any) => any>' is not assignable to type 'void | Response | Promise<void | Response>'.
      Type 'Promise<(req: any, res: any) => any>' is not assignable to type 'Promise<void | Response>'.
        Type '(req: any, res: any) => any' is not assignable to type 'void | Response'.

  57 |         __return_type__: Response | void | never | Promise<Response | void | never>
  58 |       },
> 59 |       {
     |       ^
  60 |         __tag__: 'GET',
  61 |         __return_type__: ReturnType<MaybeField<TEntry, 'GET'>>
  62 |       },

Node version: 19.3.0

My package.json:

{
  "name": "my-app",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "next lint"
  },
  "dependencies": {
    "@aws-sdk/client-s3": "^3.501.0",
    "@aws-sdk/s3-presigned-post": "^3.501.0",
    "@aws-sdk/s3-request-presigner": "^3.501.0",
    "@kinde-oss/kinde-auth-nextjs": "^2.1.5",
    "@prisma/client": "^5.7.1",
    "@radix-ui/react-avatar": "^1.0.4",
    "@radix-ui/react-dialog": "^1.0.5",
    "@radix-ui/react-dropdown-menu": "^2.0.6",
    "@radix-ui/react-navigation-menu": "^1.1.4",
    "@radix-ui/react-scroll-area": "^1.0.5",
    "@radix-ui/react-separator": "^1.0.3",
    "@radix-ui/react-slot": "^1.0.2",
    "@radix-ui/react-tabs": "^1.0.4",
    "@tailwindcss/typography": "^0.5.10",
    "@tanstack/react-query": "^4.36.1",
    "@trpc/client": "^10.44.1",
    "@trpc/next": "^10.44.1",
    "@trpc/react-query": "^10.44.1",
    "@trpc/server": "^10.44.1",
    "@types/multer": "^1.4.11",
    "aws-sdk": "^2.1545.0",
    "class-variance-authority": "^0.7.0",
    "clsx": "^2.0.0",
    "filepond": "^4.30.6",
    "filepond-plugin-file-validate-type": "^1.2.8",
    "lucide-react": "^0.316.0",
    "multer": "1.4.5-lts.1",
    "next": "14.1.0",
    "next-connect": "^1.0.0",
    "next-themes": "^0.2.1",
    "react": "^18",
    "react-dom": "^18",
    "react-dropzone": "^14.2.3",
    "react-filepond": "^7.1.2",
    "react-hook-form": "^7.49.3",
    "tailwind-merge": "^2.1.0",
    "tailwindcss-animate": "^1.0.7",
    "zod": "^3.22.4"
  },
  "devDependencies": {
    "@types/node": "^20",
    "@types/react": "^18",
    "@types/react-dom": "^18",
    "autoprefixer": "^10.0.1",
    "eslint": "^8",
    "eslint-config-next": "14.0.4",
    "postcss": "^8",
    "prisma": "^5.7.1",
    "tailwindcss": "^3.3.0",
    "typescript": "^5"
  }
}

Any idea how to fix this error?
Thanks

Library URL

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

Library version

2.1.5

Operating system(s)

Windows

Operating system version(s)

Windows 11

Further environment details

No response

Reproducible test case URL

No response

Additional information

No response

kinde-auth-nextjs fails on edge runtime

Prerequisites

Describe the issue

Unable to use the SDK with edge runtime as it crashes trying to import node crypto, probably from transient jwt-decode or crypto-js 🤷

import { getKindeServerSession } from "@kinde-oss/kinde-auth-nextjs/server";

export const runtime = "edge";

export default function Home() {
  const { getUser, isAuthenticated } = getKindeServerSession();
  const user = getUser();

  return <></>;
}
- error ./node_modules/.pnpm/@[email protected][email protected][email protected]/node_modules/@kinde-oss/kinde-auth-nextjs/dist/server/index.js:1:960
Module not found: Can't resolve 'crypto'

https://nextjs.org/docs/messages/module-not-found

Library URL

https://github.com/kinde-oss/kinde-auth-react%E2%80%9D

Library version

1.8.16

Operating system(s)

Other Linux

Operating system version(s)

.

Further environment details

next 13.4.19

Reproducible test case URL

No response

Additional information

No response

Bug: getUserOrganizations returns undefined

Prerequisites

Describe the issue

After authenticating calling the getUserOrganizations method is returning undefined when user is a member of multiple organizations

import { useKindeAuth } from '@kinde-oss/kinde-auth-react';

const { getUserOrganizations } = useKindeAuth();

// After user authentication
const userOrganizations = await getUserOrganizations();
console.log(userOrganizations);
// {orgCodes: undefined }

Expected
// {orgCodes:['org_1', 'org_2'] }

### Library URL

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

### Library version

Current

### Operating system(s)

macOS

### Operating system version(s)

Ventura

### Further environment details

_No response_

### Reproducible test case URL

_No response_

### Additional information

_No response_

Bug: `/api/auth/setup` is failing with 401 Unauthorized

Prerequisites

Describe the issue

Following the NextJS guide, I constantly see the following error in my console

Screenshot 2024-05-27 at 1 33 55 AM

This setup fetch call in this effect is always failing with 401 error.

The response just says "Login with Kinde".

At the moment it appears to be a red herring since I'm able to login anyways, but thought i'd report, since either the guide is missing a step, there's a bug with the SDK or I'm doing something wrong.

Thanks!

Library URL

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

Library version

^2.2.10

Operating system(s)

macOS

Operating system version(s)

Sonoma 14.5

Further environment details

No response

Reproducible test case URL

No response

Additional information

No response

Bug: Lack of types when updating from 1.8.25 => ^2.0.0

Prerequisites

Describe the issue

Almost every function returned from getKindeServerSession() is of type Promise<any>. For example:

    export default function Page() {
        const { getUser } = getKindeServerSession()

        // getUser returns Promise<any>, instead of Promise<KindeUser>

    }

I think that this commit is responsible for that bug: 089cda615f5238246204a148333ac8c3887a4f24

Library URL

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

Library version

^2.0.0

Operating system(s)

macOS

Operating system version(s)

Sonoma

Further environment details

No response

Reproducible test case URL

No response

Additional information

No response

Bug: 405 method not allowed - Middleware + handler don't handle non-GET requests gracefully

Prerequisites

Describe the issue

Steps

  1. Have an app with the default kinde middleware protecting most routes.
  2. After session is expired
  3. Front-end code sends a POST request to one of the api routes (or invoked a server action)
  4. Middleware redirects to POST /api/auth/login

Expected

The handler redirects to login, or better yet, allows to handle it otherwise to inform the front-end that session has expired and user needs to be logged in again.

Actual

🔴/api/auth/login?post_login_redirect_url=... 405 Method Not Allowed

Library URL

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

Library version

2.2.10

Operating system(s)

macOS

Operating system version(s)

23E224

Further environment details

No response

Reproducible test case URL

No response

Additional information

No response

Issue with getAccessToken Returning null in Next.js Application using Kinde Authentication

Prerequisites

Describe the issue

We are experiencing an issue in our Next.js application where the getAccessToken function from the @kinde-oss/kinde-auth-nextjs SDK consistently returns null even after a successful login and logout process.

Library URL

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

Library version

2.0.10

Operating system(s)

macOS

Operating system version(s)

14.1.1

Further environment details

Environment:

Node.js Version: v20.8.1
Next.js Version: 13.5.6
Kinde Auth Next.js SDK Version: 2.0.10
React Version: 18.x

Additional Dependencies:

@headlessui/react, @heroicons/react, @radix-ui/react-*, clsx, fs, lucide-react, tailwind-merge, tailwindcss-animate

Reproducible test case URL

No response

Additional information

No response

Bug: (fill in) Module not found server and components

Prerequisites

Describe the issue

Cannot find module '@kinde-oss/kinde-auth-nextjs/components' or its corresponding type declarations
I reinstall that libary but still doesn't work,
The files ```[pawitsahare@jac node_modules]$ cd @kinde-oss/kinde-auth-nextjs/
Video
Screencast from 2023-11-11 06-26-19.webm

[pawitsahare@jac kinde-auth-nextjs]$ tree
.
├── dist
│ ├── cjs
│ │ ├── index.js
│ │ └── index.js.map
│ ├── components
│ │ ├── cjs
│ │ │ ├── index.js
│ │ │ └── index.js.map
│ │ ├── index.d.ts
│ │ ├── index.js
│ │ └── index.js.map
│ ├── index.d.ts
│ ├── index.js
│ ├── index.js.map
│ ├── middleware
│ │ ├── cjs
│ │ │ ├── index.js
│ │ │ └── index.js.map
│ │ ├── index.d.ts
│ │ ├── index.js
│ │ └── index.js.map
│ ├── server
│ │ ├── cjs
│ │ │ ├── index.js
│ │ │ └── index.js.map
│ │ ├── index.d.ts
│ │ ├── index.js
│ │ └── index.js.map
│ ├── types
│ │ ├── api-client.d.ts
│ │ ├── api-client.d.ts.map
│ │ ├── components
│ │ │ ├── CreateOrgLink.d.ts
│ │ │ ├── CreateOrgLink.d.ts.map
│ │ │ ├── index.d.ts
│ │ │ ├── index.d.ts.map
│ │ │ ├── LoginLink.d.ts
│ │ │ ├── LoginLink.d.ts.map
│ │ │ ├── LogoutLink.d.ts
│ │ │ ├── LogoutLink.d.ts.map
│ │ │ ├── RegisterLink.d.ts
│ │ │ └── RegisterLink.d.ts.map
│ │ ├── config
│ │ │ ├── index.d.ts
│ │ │ └── index.d.ts.map
│ │ ├── frontend
│ │ │ ├── AuthProvider.d.ts
│ │ │ ├── AuthProvider.d.ts.map
│ │ │ ├── index.d.ts
│ │ │ ├── index.d.ts.map
│ │ │ ├── KindeBrowserClient.d.ts
│ │ │ └── KindeBrowserClient.d.ts.map
│ │ ├── handlers
│ │ │ ├── auth.d.ts
│ │ │ ├── auth.d.ts.map
│ │ │ ├── callback.d.ts
│ │ │ ├── callback.d.ts.map
│ │ │ ├── createOrg.d.ts
│ │ │ ├── createOrg.d.ts.map
│ │ │ ├── login.d.ts
│ │ │ ├── login.d.ts.map
│ │ │ ├── logout.d.ts
│ │ │ ├── logout.d.ts.map
│ │ │ ├── register.d.ts
│ │ │ ├── register.d.ts.map
│ │ │ ├── setup.d.ts
│ │ │ └── setup.d.ts.map
│ │ ├── index.d.ts
│ │ ├── index.d.ts.map
│ │ ├── middleware
│ │ │ ├── index.d.ts
│ │ │ └── index.d.ts.map
│ │ ├── routerClients
│ │ │ ├── AppRouterClient.d.ts
│ │ │ ├── AppRouterClient.d.ts.map
│ │ │ ├── PagesRouterClient.d.ts
│ │ │ ├── PagesRouterClient.d.ts.map
│ │ │ ├── RouterClient.d.ts
│ │ │ └── RouterClient.d.ts.map
│ │ ├── server
│ │ │ ├── index.d.ts
│ │ │ └── index.d.ts.map
│ │ ├── session
│ │ │ ├── getAccessToken.d.ts
│ │ │ ├── getAccessToken.d.ts.map
│ │ │ ├── getBooleanFlag.d.ts
│ │ │ ├── getBooleanFlag.d.ts.map
│ │ │ ├── getFlag.d.ts
│ │ │ ├── getFlag.d.ts.map
│ │ │ ├── getIdToken.d.ts
│ │ │ ├── getIdToken.d.ts.map
│ │ │ ├── getIntegerFlag.d.ts
│ │ │ ├── getIntegerFlag.d.ts.map
│ │ │ ├── getOrganization.d.ts
│ │ │ ├── getOrganization.d.ts.map
│ │ │ ├── getPermission.d.ts
│ │ │ ├── getPermission.d.ts.map
│ │ │ ├── getPermissions.d.ts
│ │ │ ├── getPermissions.d.ts.map
│ │ │ ├── getStringFlag.d.ts
│ │ │ ├── getStringFlag.d.ts.map
│ │ │ ├── getUser.d.ts
│ │ │ ├── getUser.d.ts.map
│ │ │ ├── getUserOrganizations.d.ts
│ │ │ ├── getUserOrganizations.d.ts.map
│ │ │ ├── index.d.ts
│ │ │ ├── index.d.ts.map
│ │ │ ├── isAuthenticated.d.ts
│ │ │ ├── isAuthenticated.d.ts.map
│ │ │ ├── kindeServerClient.d.ts
│ │ │ ├── kindeServerClient.d.ts.map
│ │ │ ├── sessionManager.d.ts
│ │ │ └── sessionManager.d.ts.map
│ │ └── utils
│ │ ├── appRouter
│ │ │ ├── prepareForRedirect.d.ts
│ │ │ ├── prepareForRedirect.d.ts.map
│ │ │ ├── setVerifierCookie.d.ts
│ │ │ └── setVerifierCookie.d.ts.map
│ │ ├── base64Encode.d.ts
│ │ ├── base64Encode.d.ts.map
│ │ ├── generateAuthUrl.d.ts
│ │ ├── generateAuthUrl.d.ts.map
│ │ ├── generateCallbackUrl.d.ts
│ │ ├── generateCallbackUrl.d.ts.map
│ │ ├── isAppRouter.d.ts
│ │ ├── isAppRouter.d.ts.map
│ │ ├── pageRouter
│ │ │ ├── isTokenValid.d.ts
│ │ │ ├── isTokenValid.d.ts.map
│ │ │ ├── prepareForRedirect.d.ts
│ │ │ ├── prepareForRedirect.d.ts.map
│ │ │ ├── setVerifierCookie.d.ts
│ │ │ └── setVerifierCookie.d.ts.map
│ │ ├── pkceChallenge.d.ts
│ │ ├── pkceChallenge.d.ts.map
│ │ ├── pkceChallengeFromVerifier.d.ts
│ │ ├── pkceChallengeFromVerifier.d.ts.map
│ │ ├── randomString.d.ts
│ │ ├── randomString.d.ts.map
│ │ ├── sanitizeRedirect.d.ts
│ │ ├── sanitizeRedirect.d.ts.map
│ │ ├── setupChallenge.d.ts
│ │ ├── setupChallenge.d.ts.map
│ │ ├── sha256.d.ts
│ │ ├── sha256.d.ts.map
│ │ ├── version.d.ts
│ │ └── version.d.ts.map
│ └── types.d.ts
├── LICENSE
├── node_modules
├── package.json
├── readme.md
└── types.d.ts

22 directories, 133 files```

I don't known why the erorr is showing but i tried using import {RegisterLink, LoginLink} from "@kinde-oss/kinde-auth-nextjs/dist/components"; still the module not found, please help also tried the building the application but still not working

./app/page.tsx:2:39

06:02:15.287 | Type error: Cannot find module '@kinde-oss/kinde-auth-nextjs/components' or its corresponding type declarations.
06:02:15.287 |  
06:02:15.287 | 1 | "use client"
06:02:15.287 | > 2 | import {RegisterLink, LoginLink} from "@kinde-oss/kinde-auth-nextjs/components";
06:02:15.287 | | ^
06:02:15.287 | 3 |
06:02:15.287 | 4 | import NextLink from "next/link";
06:02:15.288 | 5 | import React from "react";
06:02:15.381 | ELIFECYCLE  Command failed with exit code 1.
06:02:15.398 | Error: Command "pnpm run build" exited with 1

Library URL

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

Library version

2.0.5

Operating system(s)

Other Linux

Operating system version(s)

Fedora 38

Further environment details

No response

Reproducible test case URL

No response

Additional information

I tried everything that possible,

Feature request: return org names in `getOrganization` and `getUserOrganizations` helpers

Prerequisites

What is the problem you’re trying to solve?

Can't get user's orgs names. I'd like to let the user know which org they have logged into and also offer the option to switch orgs.

What solution would you like to see?

Functions getOrganization and getUserOrganizations could return not only org codes but also org names.

Additional information

using import { getKindeServerSession } from '@kinde-oss/kinde-auth-nextjs/server'

Bug: module augmentation fails due to how library publishes types

Prerequisites

Describe the issue

Steps

In user panel, enable Settings -> Applications -> ... -> Tokens -> Access Token -> Organisation Name (string)
Then augment the module to add the missing property:

// i.e. src/types/kinde.d.ts
declare module "@kinde-oss/kinde-auth-nextjs" {
  export type KindeOrganization = {
    orgName: string | null;
  };
}

Expected

KindeOrganization should now contain both orgName and orgCode

Actual

The whole module is now broken, all imports are failing, i.e.

Module '"@kinde-oss/kinde-auth-nextjs"' has no exported member 'useKindeBrowserClient'.ts(2305)

Library URL

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

Library version

2.2.3

Operating system(s)

macOS

Operating system version(s)

n/a

Further environment details

Next.js 14.2.2

Reproducible test case URL

No response

Additional information

No response

Bug: handleAuth does not match the required types of a Next.js Route

Prerequisites

Describe the issue

src/app/api/auth/[kindeAuth]/route.ts
Type error: Route "src/app/api/auth/[kindeAuth]/route.ts" does not match the required types of a Next.js Route.
  Invalid configuration "GET":
    Expected "Function", got "Promise<void | Response> | ((req: NextApiRequest | Request, res: Response | NextApiResponse<any>) => Promise<...>)".

Library URL

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

Library version

2.0.9

Operating system(s)

macOS

Operating system version(s)

14.0 (23A344)

Further environment details

No response

Reproducible test case URL

No response

Additional information

No response

I can't create user and organization by `createKindeManagementAPIClient`.

Prerequisites

Describe the issue

Basically, I want to create a signup API where I will create a separate organization for every user signed up. I planned to create an organization like this <username>'s space name. I was digging through documentation, I found this createKindeManagementAPIClient.

It has lots of helpful methods for managing kinde management API. I attempted the way below but every time I got bad request. Maybe I am making some silly mistake.

CleanShot 2024-05-28 at 8  48 04@2x

Library URL

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

Library version

^2.2.11

Operating system(s)

macOS

Operating system version(s)

14.5 (23F79)

Further environment details

No response

Reproducible test case URL

https://github.com/kingRayhan/kinde-play-org

Additional information

No response

Bug: Authentication flow state

Prerequisites

Describe the issue

When click on register link or login link it throw me HTTP 500 error code and the url which i redirect by clicking the login link is http://localhost:3000/api/auth/register?

i have app router and i have write the code for login and register link in page.js of home or root
version of next js "next": "^13.5.6",
version of kinde "@kinde-oss/kinde-auth-nextjs": "^2.0.1",
node version 16.20.0

Library URL

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

Library version

2.0.1

Operating system(s)

Other Linux

Operating system version(s)

Linux mint 20 Cinnamon ,Cinnamon version 4.6.6

Further environment details

No response

Reproducible test case URL

No response

Additional information

No response

Issue with cookie age when logging in

Hi,
I have an issue when using this SDK to login.
As i checked, when users login to Kinde, the maximum age of the code_verifer cookie is 60s
const { state, code_challenge } = setupChallenge(req, res, 60);
This is a problem if the session logs in and inserts the code in more than 60s then the SDK cannot verify because the code_verifier has been removed.
My suggestion is that the SDK allow the user to configure the maximum age of code_verifer

Feature request: Add dynamic post logout redirect urls

Prerequisites

What is the problem you’re trying to solve?

In the same way that dynamic post login urls are allowed, it would be useful to allow the same for logout.

For example to allow both:

api/auth/logout?post_logout_redirect_uri=product1/login
api/auth/logout?post_logout_redirect_uri=product2/login

What solution would you like to see?

a post_logout_redirect_uri parameter that can be passed to the logout url something like

<Link
    href={{
        pathname: "/api/auth/logout",
        query: {
            post_logout_redirect_url: "/product2/login"
        }
    }}
>
    Log out
</Link>

Additional information

No response

Bug: TypeError: (0 , react__WEBPACK_IMPORTED_MODULE_0__.createContext) is not a function

Prerequisites

Describe the issue

Hi, I just tried to get server session for isAuthenticated method for switch for two buttons display but this happen only here

import { getKindeServerSession } from "@kinde-oss/kinde-auth-nextjs/server";

export const Navs = async () => {
  const { isAuthenticated } = getKindeServerSession();

  const logged = await isAuthenticated();

  return (
    <nav className="flex gap-4">
      {logged ? (
        <div className="flex w-fit items-center gap-4">
          <Button variant={"link"} asChild>
            <Link href={"/dashboard"}>Dashboard</Link>
          </Button>
          <AccountMenu />
        </div>
      ) : (
        <div className="flex items-center gap-4">
          <Button variant={"link"} asChild>
            <LoginLink>SignIn</LoginLink>
          </Button>
          <Button variant={"link"} asChild>
            <RegisterLink>SignUp</RegisterLink>
          </Button>
        </div>
      )}
      <ModeToggle />
    </nav>
  );
};

export default Navs;

console:

TypeError: (0 , react__WEBPACK_IMPORTED_MODULE_0__.createContext) is not a function
    at eval (webpack-internal:///(rsc)/./node_modules/@kinde-oss/kinde-auth-nextjs/dist/index.js:16:11560)
    at (rsc)/./node_modules/@kinde-oss/kinde-auth-nextjs/dist/index.js (D:\Big Projects\minecraft-client\.next\server\vendor-chunks\@kinde-oss.js:30:1)
    at __webpack_require__ (D:\Big Projects\minecraft-client\.next\server\webpack-runtime.js:33:43)
    at eval (webpack-internal:///(rsc)/./app/(main)/_components/nav.tsx:9:86)
    at (rsc)/./app/(main)/_components/nav.tsx (D:\Big Projects\minecraft-client\.next\server\app\(main)\(routes)\dashboard\server\[id]\(routes)\main\page.js:563:1)
    at __webpack_require__ (D:\Big Projects\minecraft-client\.next\server\webpack-runtime.js:33:43)
    at eval (webpack-internal:///(rsc)/./app/(main)/_components/header.tsx:7:62)
    at (rsc)/./app/(main)/_components/header.tsx (D:\Big Projects\minecraft-client\.next\server\app\(main)\(routes)\dashboard\server\[id]\(routes)\main\page.js:552:1)
    at __webpack_require__ (D:\Big Projects\minecraft-client\.next\server\webpack-runtime.js:33:43)
    at eval (webpack-internal:///(rsc)/./app/(main)/layout.tsx:7:76) {
  type: 'TypeError',
  page: '/dashboard/server/MfQxfjWwo7RrBrnLeO4o/main'
}

Library URL

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

Library version

2.2.6

Operating system(s)

Windows

Operating system version(s)

Windows 11 version 22H2

Further environment details

package.json

{
  "name": "minecraft-client",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "next lint"
  },
  "dependencies": {
    "@hookform/resolvers": "^3.3.4",
    "@kinde-oss/kinde-auth-nextjs": "^2.2.6",
    "@radix-ui/react-alert-dialog": "^1.0.5",
    "@radix-ui/react-dialog": "^1.0.5",
    "@radix-ui/react-dropdown-menu": "^2.0.6",
    "@radix-ui/react-label": "^2.0.2",
    "@radix-ui/react-slot": "^1.0.2",
    "@radix-ui/react-tabs": "^1.0.4",
    "@typeschema/zod": "^0.13.3",
    "class-variance-authority": "^0.7.0",
    "clsx": "^2.1.1",
    "drizzle-orm": "^0.30.10",
    "firebase": "^10.11.1",
    "framer-motion": "^11.1.9",
    "ldrs": "^1.0.1",
    "lucide-react": "^0.378.0",
    "mineflayer": "^4.20.1",
    "net": "^1.0.2",
    "next": "14.2.3",
    "next-safe-action": "^6.2.0",
    "next-themes": "^0.3.0",
    "react": "^18",
    "react-dom": "^18",
    "react-hook-form": "^7.51.4",
    "sonner": "^1.4.41",
    "tailwind-merge": "^2.3.0",
    "tailwindcss-animate": "^1.0.7",
    "zod": "^3.23.6"
  },
  "devDependencies": {
    "@types/node": "^20",
    "@types/react": "^18",
    "@types/react-dom": "^18",
    "eslint": "^8",
    "eslint-config-next": "14.2.3",
    "postcss": "^8",
    "supabase": "^1.165.0",
    "tailwindcss": "^3.4.1",
    "typescript": "^5"
  }
}

Reproducible test case URL

No response

Additional information

No response

Bug: When unauthenticated, getToken is not a function, it just has the value undefined.

Prerequisites

Describe the issue

When unauthenticated, getToken is not a function, it just has the value undefined.

 useEffect(() => {
      console.log(`isAuthenticated: ${isAuthenticated}`);
      console.log(`getToken: ${getToken}`);
      if (getToken) {
        console.log(`getToken(): ${getToken()}`);
      }
      console.log(`user: ${JSON.stringify(user)}`);
    }, [isAuthenticated, getToken, user]);

console.log returns:

isAuthenticated: false
getToken: undefined
user: null

The issue comes from the AuthProvider file AuthContext initial state, lacks the property getToken:

const AuthContext = createContext({
  ...config.initialState,
  user: handleError,
  isLoading: handleError
});

Library URL

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

Library version

1.8.2

Operating system(s)

macOS

Operating system version(s)

macOS Ventura 13.2.1

Further environment details

All browsers
Framework: NextJS v12

Reproducible test case URL

No response

Additional information

No response

Bug: (getKindeServerSession throws an error in generateStaticParams)

Prerequisites

Describe the issue

When using the getUser function from getKindeServerSession to get the user id in generateStaticParams (Nextjs 14.0.2 App Router) inside nested page route (/posts/[slug]), it throws this error... (Error: Invariant: cookies() expects to have requestAsyncStorage, none available)

Library URL

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

Library version

1.8.25

Operating system(s)

Ubuntu

Operating system version(s)

22.04

Further environment details

Node v20
Firefox v118

Reproducible test case URL

No response

Additional information

Bug: getUser function not returning a username property

Prerequisites

Describe the issue

I'm attempting to retrieve the username property for users that have usernames set. However, the getUser method from the getKindeServerSession function only returns an object with the following properties:

{

  "family_name": "family name",

  "given_name": "given name",

  "picture": "picture_url",

  "email": "email",

  "id": "idString",

  "properties": {

    "city": undefined,

    "industry": undefined,

    "job_title": undefined,

    "middle_name": undefined,

    "postcode": undefined,

    "salutation": undefined,

    "state_region": undefined,

    "street_address": undefined,

    "street_address_2": undefined

  }

}

The username property is missing from the response despite the fact that users do have usernames set.

Steps to Reproduce

  1. Import the getKindeServerSession function from @kinde-oss/kinde-auth-nextjs/server.

  2. Call the getUser method.

  3. Observe the response object.


import { getKindeServerSession } from "@kinde-oss/kinde-auth-nextjs/server";

export default async function Home() {

  const { getUser } = getKindeServerSession();

  const user = await getUser();

  console.log(user);

  return (

    <div>

      <pre>{JSON.stringify(user, null, 2)}</pre>

    </div>

  );

}

Expected Behavior

The response object from the getUser method should include the username property if it is set for the user.

Actual Behavior

The getUser method returns an object without the username property, even for users who have usernames set.

Verification

I have contacted support and verified that users do indeed have the username property set. This was confirmed by using the Kinde Management API to retrieve user objects, which included the username property.

Environment

Package Version: @kinde-oss/kinde-auth-nextjs "^2.2.13"

Node.js Version: v21.1.0

Library URL

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

Library version

"2.2.13"

Operating system(s)

macOS

Operating system version(s)

macOS Sonoma 14.4.1

Further environment details

No response

Reproducible test case URL

No response

Additional information

No response

End of JSON input bug on log out

Prerequisites

Describe the issue

When the user logs out and the app tries to read the new authentication state, an unexpected error causes the auth state to perpetually load with the error "End of JSON Input" showing up on the client and the error below showing on the server
image

Library URL

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

Library version

"^2.1.5"

Operating system(s)

Windows

Operating system version(s)

Windows 11

Further environment details

No response

Reproducible test case URL

No response

Additional information

No response

Bug: authMiddleware doesn't work

Prerequisites

Describe the issue

With the 2.0.0 version, this does not work:

import { authMiddleware } from '@kinde-oss/kinde-auth-nextjs/server'

export const config = {
  matcher: ['/dashboard/:path*', '/auth-callback'],
}

export default authMiddleware

The matched routes are always locked, even if logged in.

This workaround works:

import { withAuth } from '@kinde-oss/kinde-auth-nextjs/server'

export const config = {
  matcher: ['/dashboard/:path*', '/auth-callback'],
}

export default withAuth(async function middleware(req: any) {}, {
  isAuthorized: ({ user }: { user: any }) => {
    return user?.id
  },
})

Library URL

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

Library version

2.0.0

Operating system(s)

macOS

Operating system version(s)

14.0

Further environment details

Next 14

Reproducible test case URL

No response

Additional information

No response

Uncaught TypeError: Cannot read properties of undefined (reading 'charAt')

Prerequisites

Describe the issue

I'm trying to use @kinde-oss/kinde-auth-nextjs on a new nextjs project, after running 'pnpm install' and 'pnpm dev', I'm getting the following error

Uncaught TypeError: Cannot read properties of undefined (reading 'charAt')
at y (webpack-internal:///(middleware)/./node_modules/.pnpm/@kinde-oss[email protected][email protected][email protected]/node_modules/@kinde-oss/kinde-auth-nextjs/dist/server/index.js:270:26)
at Object.k [as handler] (webpack-internal:///(middleware)/./node_modules/.pnpm/@kinde-oss[email protected][email protected][email protected]/node_modules/@kinde-oss/kinde-auth-nextjs/dist/server/index.js:273:38)
at adapter (webpack-internal:///(middleware)/./node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/esm/server/web/adapter.js:185:33)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Library URL

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

Library version

^1.8.18

Operating system(s)

Other (see “Further environment details”)

Operating system version(s)

Windows 11

Further environment details

WSL 2 Ubuntu

Reproducible test case URL

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

Additional information

No response

Bug: useKindeBrowserClient doesn't work with basePath

Prerequisites

Describe the issue

Issue
When using kinde-auth-nextjs with app dir routing and a basePath set, useKindeBrowserClient cannot be used.

Cause
The fetch("/api/auth/setup") located here doesn't take the basePath into consideration. The result is a 404 Not Found and no auth data returned.

Resolution
Not quite sure right now to be honest. You used to be able to get the basePath from the router, but that was removed in 14. Perhaps another env var? Or an optional options argument for useKindeBrowserClient. I can submit a PR if you wish with your desired plan of attack.

Library URL

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

Library version

2.1.7

Operating system(s)

Other Linux

Operating system version(s)

Arch Linux

Further environment details

No response

Reproducible test case URL

No response

Additional information

No response

Bug: Broken type exports since 2.2.2

Prerequisites

Describe the issue

Since v2.2.2 the type exports have changed, which breaks my integration and it no longer seems possible to import certain types, especially KindeAccessToken, KindeIdToken and KindeUser that were previously exposed through import type { KindeAccessToken, KindeIdToken, KindeUser } from '@kinde-oss/kinde-auth-nextjs/types';

Those types now live in dist/types.d.ts but there is no export for those in package.json and they do not seem to be re-exported through any other exports listed there.

It'd be great if you could expose them again or provide information how we can still access them. I would not consider this a minor change unless those types were never meant to be exposed.

Library URL

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

Library version

2.2.2

Operating system(s)

macOS

Operating system version(s)

14.2.1

Further environment details

No response

Reproducible test case URL

No response

Additional information

No response

Bug: Edge deployment API Route Error

Prerequisites

Describe the issue

When deployed to CF Pages via the @cloudflare/next-on-pages package, user requests to /api/auth/[kindeAuth] are not resolved correctly and show a "Internal Server Error"

This does not happen in development and seems to also affect Vercel deployments as well.

CF Pages Log:
image

User Facing:
image

image

Library URL

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

Library version

2.0.13

Operating system(s)

macOS

Operating system version(s)

14.2 Beta (23C5030f)

Further environment details

No response

Reproducible test case URL

No response

Additional information

There are no changes to the library or any special changes to how this library is implemented.

The most recent docs have followed word for word and since the entire auth flow works on development, I can assume I set it up correctly

I can share my project on a person-by-person basis

refreshTokens in Next.js results in ReferenceError: config is not defined

Prerequisites

Describe the issue

Wanted to try out the new refreshTokens as documented here:
https://docs.kinde.com/developer-tools/sdks/backend/nextjs-sdk/#refreshing-kinde-data

await refreshTokens() ...always results in "ReferenceError: config is not defined"

Poked around in the repo: https://github.com/kinde-oss/kinde-auth-nextjs/blob/55de0cae4618fb83bb27d23faa616ec9cebbbff0/src/session/index.js

I don't see where the config object that is accessed on line 35 is defined or imported. It would only reach that spot if another error occurred, but I can't see what that might be yet.

Library URL

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

Library version

2.2.6

Operating system(s)

Windows

Operating system version(s)

Windows 10 Pro

Further environment details

No response

Reproducible test case URL

No response

Additional information

No response

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.