Add custom headers to 301 redirect in workers


Hey guys,
I am trying to do a 301 redirect from domain A to domain B, so far so good :slight_smile:
However I want to pass custom headers along with it and I am not sure how to do that… Some help would be appreciated!

My code on domain A:

addEventListener('fetch', event => {

async function handleRedirectTo(request) {
  let redirectHeaders = new Headers()
  redirectHeaders.set('Location', '')
  redirectHeaders.set('x-from-Domain-A', 'true')

  return new Response('', {
			status: 302,
			headers: redirectHeaders

And my code on domain B:

addEventListener('fetch', event => {

async function handleRedirectFrom(request) {
  let response = await fetch(request)
  return response