Add API middleware
Merge remote-tracking branch 'upstream/develop' into develop