This needs to go into the middleware on the core/ui/index.js