write response based on redirect body instead of simply redirecting for api requests