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

[Spike] Cookie Parsing #53

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

[Spike] Cookie Parsing #53

wants to merge 1 commit into from

Conversation

tabazevedo
Copy link

  • Client-side setting of cookies
  • Server-side setting of cookies
  • Parse cookies in form processing

The premise of this is that cookies live in your app state.

Calling

app-state.get('cookies.user').update(function(){
  return {
    value: 'person',
    options: {
      httpOnly: true,
      secure: true
    }
  };
});

from anywhere will set cookies for that environment. When done server-side, it will tell the client to keep that cookie header. Options adhere to RFC6265 (uses https://github.com/expressjs/cookie-parser and https://github.com/jshttp/cookie behind the scenes)

The cookies state piece is populated on the server from client cookie headers and the app can access them that way.

To clear/unset a cookie:
app-state.get('cookies.user').update(function(){ return null });

Also fixed in this:

  • Form processing breaking when on-change handler not present (e.g. hidden input field)
  • Route observables not being called server-side (for both form processing and SSR)

@charypar
Copy link
Member

❤️ this is brilliant.

@charypar
Copy link
Member

I'm now thinking we could change the redirect API to go through updating the route path in app-state instead of a special API call... :)

I'm a little worried about creating a massive state schema for these things though... Need to be careful with the balance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants