diff --git a/packages/dashboard/src/pages/api/redirect.js b/packages/dashboard/src/pages/api/redirect.js index 69da40a5..66268a26 100644 --- a/packages/dashboard/src/pages/api/redirect.js +++ b/packages/dashboard/src/pages/api/redirect.js @@ -1,6 +1,22 @@ +import superagent from "superagent"; import { serialize } from "cookie"; -export default (req, res) => { - res.setHeader("Set-Cookie", serialize("foo", Math.random(), {})); +export default async (req, res) => { + console.log(Object.keys(req)); + console.log(req.url); + console.log(req.cookies); + console.log(req.rawHeaders); + try { + const auth = await superagent + .set("Cookie", serialize("ory_kratos_session", req.cookies.ory_kratos_session)) + .get("/user"); + + console.log(auth.header); + + res.setHeader("Set-Cookie", auth.header["set-cookie"]); + } catch (error) { + console.log(error); + } + res.redirect(302, req.query.return_to); };