API authed middleware fix