Fearless CORS: a design philosophy for CORS middleware libraries (and a Go implementation)
TL;DR ¶ In this post, I investigate why developers struggle with CORS and I derive Fearless CORS, a design philosophy for better CORS middleware libraries, which comprises the following twelve principles:
Optimise for readability Strive for a simple and cohesive API Provide support for Private Network Access Categorise requests correctly Validate configuration and fail fast Treat CORS as a compilation target Provide no default configuration Do not preclude legitimate configurations Ease troubleshooting by eschewing shortcuts during preflight Render insecure configurations impossible Guarantee configuration immutability Focus performance optimisation on middleware execution This post also introduces jub0bs/fcors, an open-source, production-ready CORS middleware library for Go that adheres to Fearless CORS.
jub0bs.com