Refactored CORS middleware into its own package