Giter VIP home page Giter VIP logo

Comments (7)

DanielRivers avatar DanielRivers commented on August 24, 2024 1

This is current intended behaviour. Due to security measures the access token cookie is not readable by javascript so the browser knows nothing about the user. This /setup endpoint returns the data about the user based on cookie access token to the browser can setup the browser client.

The 401 happens when the user is not signed in as no token is present it doesn't have access to the route.

This is something we want to improve in the future.

from kinde-auth-nextjs.

DanielRivers avatar DanielRivers commented on August 24, 2024 1

Sadly, 401 errors cannot be omitted from the console. They are always outputted there is no way to prevent this.

from kinde-auth-nextjs.

AntoLepejian avatar AntoLepejian commented on August 24, 2024 1

TIL. I guess you'd have to return 200 { isLoggedIn: boolean } and reserve 401 for real unauthorised access attempts. Which is a slightly bigger job.

No worries then thanks for looking into this!

from kinde-auth-nextjs.

AntoLepejian avatar AntoLepejian commented on August 24, 2024

I just realised that this is 401ing only when there's no active user session, and once I login the request to /api/auth/setup succeed.

Sounds like a bug in the useEffect, which shouldn't fire if there's no active user session.

For reference, this is the problematic code

  const { user } = useKindeBrowserClient();

IIUC that's how I'm meant to check if a user is logged in or not, and hence there should be no call to /setup if it requires an active user session.

from kinde-auth-nextjs.

AntoLepejian avatar AntoLepejian commented on August 24, 2024

I see thank you!

@DanielRivers should we handle the request rejection and swallow it then to avoid spamming the console?

If it's intended behaviour, there's a low-hanging fix to wrap it in a try/catch, and swallow the 401 errors? If it's any other status code we can rethrow.

Either way I'll leave it with you and the team 🙂

from kinde-auth-nextjs.

Related Issues (20)

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.