Skip to content

Commit

Permalink
add a few cookie options
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Zuniga Cuellar committed Oct 2, 2023
1 parent 6367ad8 commit f1d20ca
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
12 changes: 10 additions & 2 deletions src/pages/api/auth/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,15 @@ export const GET: APIRoute = async ({ url, cookies, redirect }) => {
}

const { access_token, refresh_token } = data.session;
cookies.set("sb-access-token", access_token, { path: "/" });
cookies.set("sb-refresh-token", refresh_token, { path: "/" });
cookies.set("sb-access-token", access_token, {
path: "/",
secure: true,
httpOnly: true,
});
cookies.set("sb-refresh-token", refresh_token, {
path: "/",
secure: true,
httpOnly: true,
});
return redirect("/dashboard");
};
12 changes: 10 additions & 2 deletions src/pages/api/auth/signin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,15 @@ export const POST: APIRoute = async ({ request, cookies, redirect }) => {
}

const { access_token, refresh_token } = data.session;
cookies.set("sb-access-token", access_token, { path: "/" });
cookies.set("sb-refresh-token", refresh_token, { path: "/" });
cookies.set("sb-access-token", access_token, {
path: "/",
secure: true,
httpOnly: true,
});
cookies.set("sb-refresh-token", refresh_token, {
path: "/",
secure: true,
httpOnly: true,
});
return redirect("/dashboard");
};

0 comments on commit f1d20ca

Please sign in to comment.