-
-
Notifications
You must be signed in to change notification settings - Fork 252
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
Getting 500 error after logout #353
Comments
Hey there, can you create a reproducible example of this bug? Thanks |
hi this is my logout codes: import { withSession } from "../../../helpers/with-session";
import axios from "axios";
const BASE_SERVER_URL = process.env.BASE_URL;
export default withSession(async function (req, res) {
try {
const menchicoSessionCookie =
req.session.get("user")?.menchicoSessionCookie;
if (menchicoSessionCookie)
try {
await axios(BASE_SERVER_URL + "/users/logout", {
method: "post",
headers: {
Cookie: menchicoSessionCookie,
},
});
} catch (error) {
console.log(error);
}
req.session.destroy();
res.json({ isLoggedIn: false });
} catch (error) {
console.log(error);
}
}); and this is import { withIronSession } from "next-iron-session";
export function withSession(handler) {
return withIronSession(handler, {
cookieName: "menchico",
password: process.env.IRON_SESSION_COOKIE_PASSWORD,
cookieOptions: {
secure: process.env.NODE_ENV == "production",
httpOnly: process.env.NODE_ENV == "production",
},
});
} first time is ok and i get this cookie:
packages: "react": "^17.0.2",
"react-dom": "^17.0.2",
"next": "^11.0.0",
"next-iron-session": "^4.2.0", |
@ukasyah99 your problem solved? |
Please if you have this issue, create a GitHub repository where we can npm install npm start and steps to take to get the 500 error. The repository must be based on the Next.js example of this repo. |
https://github.com/BahmanBinary/iron-session-issue |
@vvo |
whats up @vvo ? |
Hey @BahmanBinary I tried to reproduce it. But it works all the time for me. I cloned the repository, npm install npm run dev and tested routes multiple times but always got 200 OK. If you can manage to reproduce it again let me know. There must be something different in your setup than mine I guess. Could be a browser configuration or extension |
@vvo Try changing the cookie value to something random then trying to login/logout - thats when I get the error. Basically when doing queries in Insomnia the cookie value is erased but the cookie still exists. GraphiQL deletes it so works fine. I imagine some browsers are deleting and some aren't. Can you try this and get back to us? |
I'm using next (10.2.3) and next-iron-session (4.1.13).
After logout (destroying session), the cookie would be like this:
When I tried login, I got Internal Server Error. But, it's back to normal after manually clearing browser cookies (on client). The error is similar to #183.
The text was updated successfully, but these errors were encountered: