bun-http-server

Build HTTP servers and REST APIs using Bun.serve request handlers.

Updated Jun 22, 2026
One-click install
npx skills add https://github.com/aicodepro/ai-agent-nexi --skill bun-http-server-aicodepro
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: bun-http-server
Source: https://github.com/aicodepro/ai-agent-nexi/tree/main/agent/skills/bun-http-server
Command: npx skills add https://github.com/aicodepro/ai-agent-nexi --skill bun-http-server-aicodepro

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Setting up an HTTP server in Bun requires knowing the Bun.serve API surface, including fetch handlers, body parsing, routing, CORS, and error handling, which developers often piece together from scattered documentation. ## Core Features & Use Cases - Request Handling: Parse methods, paths, query params, headers, and bodies (JSON, form data, text, ArrayBuffer, Blob) inside a single fetch handler. - Routing & Responses: Implement static and dynamic routes returning JSON, HTML, redirects, files, and streams with proper status codes. - Server Configuration: Configure ports, hostnames, TLS, Unix sockets, body size limits, CORS headers, and global error handlers. - Use Case: Build a REST API endpoint like GET /api/users/:id that parses the URL, returns JSON, handles 404s, and includes CORS headers for browser clients. ## Quick Start Ask the assistant to create a Bun HTTP server on port 3000 with a JSON API route and error handling.

Frequently Asked Questions about bun-http-server

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create an HTTP server with Bun.serve?

Call Bun.serve with a port and a fetch handler that receives a Request and returns a Response. The server starts immediately, and you can read server.port and server.url for connection info.

How to parse JSON request bodies in Bun server?

Use await req.json() inside the fetch handler to parse JSON bodies. Bun also supports req.formData(), req.text(), req.arrayBuffer(), and req.blob(), but each body can only be consumed once.

How do I implement routing in a Bun HTTP server?

Parse new URL(req.url) to get the pathname, then match it against static paths or regex patterns for dynamic segments like /api/users/:id. Combine with req.method checks to handle GET, POST, and other verbs.

Does Bun.serve support HTTPS and TLS?

Yes, pass a tls option with key and cert loaded via Bun.file to enable HTTPS. The skill also references additional TLS and mTLS configuration in its references documentation.

Why does my Bun server throw EADDRINUSE?

EADDRINUSE means the port is already occupied by another process. Either stop the conflicting process or configure Bun.serve to listen on a different port.

How do I add CORS headers to Bun server responses?

Return Access-Control-Allow-Origin, Methods, and Headers on every response, and handle OPTIONS preflight requests by returning an empty response with those headers. This allows browser clients from other origins to call the API.