lukeed / polka

A micro web server so fast, it'll make you dance! :dancers:
MIT License
5.42k stars 174 forks source link

res.cookie is not a function #144

Closed zakaria-chahboun closed 4 years ago

zakaria-chahboun commented 4 years ago

I want to use the package cookie-parser BUT I can't use cookie function in res in my middleware! it gives me an error message res.cookie is not a function

my code look like this:

import cookieParser from "cookie-parser";
polka()
    // - body parser
    .use(json())
    // - cookies parser
    .use(cookieParser())
    .all("*", (req, res, next) => {
        res.cookie("XSRF-TOKEN", req.csrfToken());
        next();
    })
lukeed commented 4 years ago

Correct, it is not. You have to set it up yourself (until there's an official package, which is definitely planned).

Until then, copying the cookie example works great: https://github.com/lukeed/polka/issues/83#issuecomment-455289371