import Koa from "koa"; import bodyParser from "koa-bodyparser"; const app = new Koa(); app.use(bodyParser()); app.use(async (ctx) => { if (ctx.request.method === "POST") { const { cookie } = ctx.request.body as { cookie: string }; ctx.set("Set-Cookie", [ `cookie-none=${cookie.replace(/[^A-Za-z0-9]+/g, '-')}; SameSite=None; Secure`, `cookie-lax=${cookie.replace(/[^A-Za-z0-9]+/g, '-')}; SameSite=Lax; Secure`, ]); ctx.redirect( "/"); } else { ctx.body = `
${JSON.stringify(Object.fromEntries(Object.entries(ctx.request.headers)), null, 2)}
Cookie SameSite=None: ${ctx.cookies.get("cookie-none")?.replace(/
Cookie SameSite=Lax: ${ctx.cookies.get("cookie-lax")?.replace(/
Browser supports storage access API:
Page can store cookies:
`; } }); app.listen(7860);