From 569259814319e1244668a9bf4b0fcee5cf196f18 Mon Sep 17 00:00:00 2001 From: Eric Date: Mon, 15 Apr 2024 19:51:50 -0500 Subject: [PATCH] Website: update guaranteed locals in custom hook (#18296) Closes: #18295 Changes: - Updated the custom hook to set `res.locals` for HEAD requests to prevent 500 errors when a request is sent to a page that references `res.locals.me` --- website/api/hooks/custom/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/api/hooks/custom/index.js b/website/api/hooks/custom/index.js index 8b579bd690..9b2a129c82 100644 --- a/website/api/hooks/custom/index.js +++ b/website/api/hooks/custom/index.js @@ -123,9 +123,9 @@ will be disabled and/or hidden in the UI. var url = require('url'); - // First, if this is a GET request (and thus potentially a view), + // First, if this is a GET request (and thus potentially a view) or a HEAD request, // attach a couple of guaranteed locals. - if (req.method === 'GET') { + if (req.method === 'GET' || req.method === 'HEAD') { // The `_environment` local lets us do a little workaround to make Vue.js // run in "production mode" without unnecessarily involving complexities