Check for empty content-type header.

This commit is contained in:
Mike Cao 2022-03-11 22:17:47 -08:00
parent 93f15bc44b
commit 785d41b6d3
2 changed files with 2 additions and 2 deletions

View File

@ -4,7 +4,7 @@
"es2020": true, "es2020": true,
"node": true "node": true
}, },
"extends": ["eslint:recommended", "plugin:react/recommended", "prettier", "next"], "extends": ["eslint:recommended", "plugin:react/recommended", "prettier"],
"parserOptions": { "parserOptions": {
"ecmaFeatures": { "ecmaFeatures": {
"jsx": true "jsx": true

View File

@ -88,7 +88,7 @@ export async function getClientInfo(req, { screen }) {
} }
export function getJsonBody(req) { export function getJsonBody(req) {
if (req.headers['content-type'].indexOf('text/plain') !== -1) { if ((req.headers['content-type'] || '').indexOf('text/plain') !== -1) {
return JSON.parse(req.body); return JSON.parse(req.body);
} }