Fixed cors issue where throwing an exception was causing a response to be sent without the cors header