Skip to content

Commit

Permalink
fix: add error handling for attempts to access pages with content-typ…
Browse files Browse the repository at this point in the history
…e other than json (#319)
  • Loading branch information
mateusznarowski authored and mercs600 committed Nov 8, 2023
1 parent bf64350 commit 632b88b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/lib/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ async function contextMiddleware (context) {
const response = await app.$typo3.api.getPage(path)
const { data } = response

const contentType = response.headers['content-type']
if (contentType && !contentType.includes('application/json')) {
return setErrorContext(context, { response: { status: 415, message: 'Unsupported content-type: \'application/json\' expected.' } })
}

if (context.res) {
setResponseHeaders(context, response.headers)
}
Expand Down

0 comments on commit 632b88b

Please sign in to comment.