Security defaults that belong in every Go HTTP server from day one — CORS, security headers, rate limiting, SQL injection prevention, input validation, secrets management, graceful shutdown, and request timeouts.
89
83%
Does it follow best practices?
Impact
99%
1.32xAverage score across 5 eval scenarios
Passed
No known issues
A startup has built a React dashboard at http://localhost:5173 and https://dashboard.example.com that needs to talk to a Go REST API. The frontend engineers are seeing CORS errors in the browser console and the security team has flagged that the server responses are missing several browser security headers. The Go API currently has no CORS configuration or security headers at all.
Your job is to build a small Go HTTP server that exposes two endpoints and is properly configured to work with the React dashboard. The API should handle cross-origin requests safely and add the standard browser security headers that the security team requires.
Create a Go module in the ./api/ directory. The server should:
GET /api/health returning {"status":"ok"}GET /api/items returning a JSON array of items (can be hardcoded sample data)The server must be runnable with go run ./api/ and should listen on port 8080 by default. Produce a README.md in ./api/ describing how to configure and run the server, including what environment variables it accepts.
Write a verify.sh script that starts the server in the background, makes a couple of test requests with curl including preflight OPTIONS requests, captures the response headers to a file header_dump.txt, then stops the server.