Git Product home page Git Product logo

Comments (1)

phoenix-ru avatar phoenix-ru commented on August 25, 2024

I see your point - you want to attach cookies server-side instead of manually setting them on the client. This is very tricky due to the fact local provider works with both Nuxt/non-Nuxt backends and authentication markers (cookies, etc.) greatly differ between all of them.
useCookie is mostly used to preserve state (i.e. tokens) within the session and cookies being set on SSR is mostly a side-effect.
I agree that it's better if JS has no access to the cookie, however in that case we also have no reliable way of knowing the authentication state:

  • SSR sees the cookie and says that a user is authenticated -> renders authenticated view;
  • CSR hydrates but doesn't see the cookie -> hydration mismatch -> renders unauthenticated view.

Not relying on useCookie at the client means that authentication state needs to be correctly set on the server and then transferred and preserved in memory during the session. This is of course doable but requires noticeable effort to think through and implement. I would love to hear your take on how it can be implemented using known building blocks of Nuxt (like useCookie and useState).

Concepts are welcome

from nuxt-auth.

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.