File size: 665 Bytes
c24174e
eed224b
c24174e
 
 
eed224b
cd60ce3
0fb7b7d
eed224b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cd60ce3
c24174e
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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.cookies.set("cookie", cookie);
    ctx.redirect( "/");
  } else {
    ctx.body = `<html>
    <body>
      <pre>${JSON.stringify(Object.fromEntries(Object.entries(ctx.request.headers)), null, 2)}</pre>
      <form method="POST">
        <label>Cookie value<br>
          <input type="text" name="cookie />
        </label>
        <button>Send</button>
      </form>
    </body>
  </html>`;
  }
});

app.listen(7860);