Skip to content

Commit

Permalink
FCRM-4556 added header dump to home
Browse files Browse the repository at this point in the history
  • Loading branch information
markfee committed Nov 23, 2023
1 parent cae5530 commit 840a86b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
7 changes: 7 additions & 0 deletions server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ async function createServer () {
})
}

server.ext('onRequest', (request, h) => {
// console.log('\nonRequest.headers', request.headers)
// console.log('\nonRequest.response', request.response)

return h.continue
})

server.ext('onPreResponse', async (request, h) => {
request.response.header('cache-control', 'no-cache')
request.response.header('Strict-Transport-Security', 'max-age=31536000; includeSubDomains; preload')
Expand Down
6 changes: 5 additions & 1 deletion server/routes/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ module.exports = [{
description: 'Home Page',
handler: async (request, h) => {
if (typeof request.yar === 'undefined' || typeof request.yar.get('displayError') === 'undefined') {
return h.view('home', { allowRobots: true })
// return h.view('home', { allowRobots: true, headers: JSON.stringify(request.headers) })
const headers = JSON.stringify(request.headers)
// console.log('\nhome\ Request.headers', request.headers)
// console.log('\nhome\ Request.headers Stringified', headers)
return h.view('home', { allowRobots: true, headers: encodeURIComponent(headers) })
} else {
const errMess = request.yar.get('displayError')
request.yar.set('displayError', {})
Expand Down
5 changes: 5 additions & 0 deletions server/views/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -135,5 +135,10 @@ <h2 class="govuk-heading-m" id="subsection-title">

</div>
</div>
<script>
document.addEventListener("DOMContentLoaded", () => {
console.log("decodeURIComponent - headers\n", JSON.parse(decodeURIComponent("{{headers}}")))
})
</script>

{% endblock %}

0 comments on commit 840a86b

Please sign in to comment.