Website: update custom hook to prevent 500 error from HEAD requests. (#17331)

Changes:
- Updated the custom hook to set `res.locals.primaryBuyingSituation` for
HEAD requests to prevent 500 errors when `primaryBuyingSituation` is not
set to `undefined`.
This commit is contained in:
Eric 2024-03-03 17:30:21 -06:00 committed by GitHub
parent fd80b47a9d
commit 302c594046
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -156,7 +156,7 @@ will be disabled and/or hidden in the UI.
// FUTURE: Auto-redirect without the querystring after absorbtion to make it prettier in the URL bar.
// (except this probably messes up analytics so before doing that, figure out how to solve that problem)
}//fi
if (req.method === 'GET') {
if (req.method === 'GET' || req.method === 'HEAD') {
// Include information about the primary buying situation
// If set in the session (e.g. from an ad), use the primary buying situation for personalization.
res.locals.primaryBuyingSituation = req.session.primaryBuyingSituation || undefined;