proxy: return JSON errors

Fix #1630
this is almost certainly going to need rate-limiting. A TODO is fine though.