serveStatic set headers

Is there any way to set response headers/cookies/etc when using serveStatic? None of the existing functions which adding/modifying the response, are working with serveStatic.
Context: I’m using serveStatic inside router .catch route.

Yes, you can use ResponseWriter.setResponseHeader(key ,value). Here’s an example:

  router.catch(500, ({ setResponseHeader, serveStatic }) => {
    setResponseHeader('some-header', 'some-value')
    setResponseHeader('cookie', 'foo=bar')
    serveStatic('public/broken-origin-500-page.html', {
      statusCode: 502,
    })
  });

Thank you for the quick answer. I’ve had an await statement for some reason before catch handler, and this was silently failing it.

@mark.brocato I was also trying to pass error message within .catch statement to the client via cookie header, setResponseHeader('set-cookie', 'err=${res:body}'), but this returns null. Can you suggest any other way to retrieve error message from crashed route?