This project contains:
- A simple HTTP server with two endpoints:
/redirect: responds with a302redirect to/final/final: responds with a200 OKand a message
- A custom
undici.Clientwith 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
undicimanually:
npm install undiciOpen 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.jsTo see the full url with the extra slash run:
NODE_DEBUG=undici node client.js