return to test
This commit is contained in:
parent
1e52938e51
commit
551debf703
|
@ -13,6 +13,7 @@
|
||||||
"@tailwindcss/forms": "^0.2.1",
|
"@tailwindcss/forms": "^0.2.1",
|
||||||
"autoprefixer": "^10.2.4",
|
"autoprefixer": "^10.2.4",
|
||||||
"classnames": "^2.2.6",
|
"classnames": "^2.2.6",
|
||||||
|
"cookie": "^0.4.1",
|
||||||
"dayjs": "^1.10.4",
|
"dayjs": "^1.10.4",
|
||||||
"express-jwt": "^6.0.0",
|
"express-jwt": "^6.0.0",
|
||||||
"formik": "^2.2.6",
|
"formik": "^2.2.6",
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
import { serialize } from "cookie";
|
||||||
|
|
||||||
|
export default (req, res) => {
|
||||||
|
res.setHeader("Set-Cookie", serialize("foo", Math.random(), {}));
|
||||||
|
res.redirect(302, req.query.return_to);
|
||||||
|
};
|
|
@ -8,6 +8,7 @@ const kratos = new PublicApi(new Configuration({ basePath: config.kratos.public
|
||||||
|
|
||||||
export async function getServerSideProps(context) {
|
export async function getServerSideProps(context) {
|
||||||
const flow = context.query.flow;
|
const flow = context.query.flow;
|
||||||
|
const redirect = encodeURIComponent(`/api/redirect?return_to=${context.query.return_to ?? "/"}`);
|
||||||
|
|
||||||
if (process.env.NODE_ENV === "development") {
|
if (process.env.NODE_ENV === "development") {
|
||||||
return { props: { flow: require("../../../stubs/login.json") } };
|
return { props: { flow: require("../../../stubs/login.json") } };
|
||||||
|
@ -21,7 +22,7 @@ export async function getServerSideProps(context) {
|
||||||
return {
|
return {
|
||||||
redirect: {
|
redirect: {
|
||||||
permanent: false,
|
permanent: false,
|
||||||
destination: `${config.kratos.browser}/self-service/login/browser?return_to=${context.query.return_to}`,
|
destination: `${config.kratos.browser}/self-service/login/browser?return_to=${redirect}`,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -36,7 +37,7 @@ export async function getServerSideProps(context) {
|
||||||
return {
|
return {
|
||||||
redirect: {
|
redirect: {
|
||||||
permanent: false,
|
permanent: false,
|
||||||
destination: `${config.kratos.browser}/self-service/login/browser?return_to=${context.query.return_to}`,
|
destination: `${config.kratos.browser}/self-service/login/browser?return_to=${redirect}`,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue