Correctly set page header if error occurs in JS.