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

req.cookies is not filled #96

Closed
LoganTann opened this issue Jul 3, 2022 · 5 comments · Fixed by #97
Closed

req.cookies is not filled #96

LoganTann opened this issue Jul 3, 2022 · 5 comments · Fixed by #97

Comments

@LoganTann
Copy link

Hello,

I'm actually creating a session system for my project. I need to read and store a session id from cookie.

Expected behavior : if the user holds a cookie with name session, then a controller requesting req.cookies.session should hold the cookie value

Current behavior : the object req.cookies is an empty object. However, req.headers.cookie contains the raw data so a quickfix is easy.

Screenshot :

image


Also, when I save values in req.cookie, I need to use the following code in an outgoing middleware to sync with res.cookie

if (!res.cookies["session"]) {
    res.cookies["session"] = req.cookies["session"];
}
@predetermined
Copy link
Owner

Is your repo maybe public or do you have a reproducible example?

@predetermined
Copy link
Owner

But regarding the last point: Yes, setting the cookie on the request won't do anything - it's the correct behaviour.

But could maybe be made more obvious by only providing a getter - will be changed in v2.

@LoganTann
Copy link
Author

Hello, thanks for the quick reply !

You can look here the code in which I added my session system and used cookies : LoganTann/redbeansoup-v2@9b7ea5d

If you want to run the entire repo, then use the following command line argument : deno run --import-map import_map.json --no-check --allow-all --watch mod.ts --start-dashboard-only

You may need to create the file config.ts with the following content (no need to fill) :

export default {
    // Discord Developers -> Oauth2 -> Client ID
    CLIENT_ID: "",
    // Discord Developers -> Oauth2 -> Client secret
    CLIENT_SECRET: "",
    // Discord Developers -> Bot -> reset
    BOT_TOKEN: "",
    // Right Click on your dev server icon -> Copy ID
    DEV_GUILD_ID: "",
    // Get your OpenAI token in your dashboard - https://openai.com/api/
    OPENAI_TOKEN: "",
    WHOLESOME_ENDPOINT: "",
};

@LoganTann
Copy link
Author

omg you fixed it before my reply, so fast xD

thanks a lot, i'll look into that PR

@predetermined
Copy link
Owner

Thanks a lot for opening the issue! 🙌 Fix released with v1.3.5

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 a pull request may close this issue.

2 participants