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

Logout #4

Open
AriaFantom opened this issue Jan 3, 2022 · 2 comments
Open

Logout #4

AriaFantom opened this issue Jan 3, 2022 · 2 comments

Comments

@AriaFantom
Copy link

Can u please help for the logout?

@simxnet
Copy link

simxnet commented Jan 5, 2022

Just make a api route to delete all cookies.

@ibadus
Copy link

ibadus commented Jan 8, 2022

If still needed, here is a solution

/api/logout.ts

import { NextApiRequest, NextApiResponse } from "next";
import { serialize } from "cookie";

// Get our environment variables
const { COOKIE_NAME } = process.env;

export default async (_: NextApiRequest, res: NextApiResponse) => {
	// remove cookie from request header
	res.setHeader("Set-Cookie", [
		serialize(COOKIE_NAME, "", {
			maxAge: -1,
			path: "/",
		}),
	]);

	res.writeHead(302, { Location: "/" });
	res.end();
};

@Turtlepaw Turtlepaw mentioned this issue Apr 9, 2022
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.

3 participants