This project contains:
- A simple HTTP server with two endpoints:
/redirect
: responds with a302
redirect to/final
/final
: responds with a200 OK
and a message
- A custom
undici.Client
with redirect handling logic usingRedirectHandler
project-root/ ├── server.js # HTTP server that serves /redirect and /final ├── client.js # Undici client with redirect logic ├── package.json
- Node.js v18+ (Undici is built-in)
- For Node.js < 18, install
undici
manually:
npm install undici
Open a terminal and run:
node server.js
This starts the HTTP server on http://localhost:3000
You can test it in your browser:
- http://localhost:3000/redirect → Redirects to
/final
- http://localhost:3000/final → Shows success message
In a separate terminal, run:
node client.js
To see the full url with the extra slash run:
NODE_DEBUG=undici node client.js