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

Question - not an issue #173

Closed
mylastore opened this issue May 7, 2020 · 1 comment
Closed

Question - not an issue #173

mylastore opened this issue May 7, 2020 · 1 comment

Comments

@mylastore
Copy link

Does anyone knows how to store JWT token in a cookie with koa-jwt?

@sdd
Copy link
Collaborator

sdd commented May 17, 2020

Setting a cookie is not something that koa-jwt has in its remit. Its quite simple to do without any libraries though:

    // somewhere inside a koa middleware function:
    
    const jwt = 'blah:blah:blah';   // if this is the JWT that you want to set as a cookie

    const cookieOptions = {
        // see here for options:
        // https://koajs.com/#ctx-cookies-set-name-value-options-
    };
    
    // COOKIE_NAME should match `opts.cookie` that is passed to koa-jwt,
    // if koa-jwt is authenticating against the cookie that you want to set
    ctx.cookies.set(COOKIE_NAME, jwt, options); 
    

@sdd sdd closed this as completed May 17, 2020
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

No branches or pull requests

2 participants