How to change `location` header from absolute to relative on proxied page?

On one project we have tons of proxied pages with upstream

Few of pages return location header with absolute url starts with

How could we change location header to relative one in proxy rule for router?

Seems like we have solution for that

.match({ path: '/your-path-here' }, async res => {
      await res.proxy('legacy', {
        transformResponse: res => {
          const locationHeader = res.getHeaders().location
          if (res.statusCode === 302 && locationHeader) {

@freewayspb That code will run every request through serverless, which will be unnecessary and costly. Instead you can use a regex to refine the location header at the edge. See

new Router()
   .get('/some/path', ({ updateResponseHeader, proxy }) => {
     updateResponseHeader('some-header', /some-.*-part/gi, 'some-replacement')