serve icon indicating copy to clipboard operation
serve copied to clipboard

Allow removal of a header

Open lorensr opened this issue 7 years ago • 8 comments

I'd like to be able to set a default header and then override it to nonexistance. When I do the below, a header with null shows up, versus the header disappearing. Ditto with max-age=0. And when I do "headers": [], it gets 86400 from the first rule.

image

image

cc @leo

lorensr avatar Jun 21 '18 21:06 lorensr

Setting a header to null should definitely remove it! 👍

leo avatar Jul 02 '18 19:07 leo

Hey @leo, I tried to use null but still serves it as null instead of deleting it.

I made a PR that solves it.

Ref: https://github.com/zeit/serve-handler/pull/45

wellingguzman avatar Aug 17 '18 01:08 wellingguzman

This ticket can be closed. It was solved by https://github.com/zeit/serve-handler/pull/45

wellingguzman avatar Aug 22 '18 22:08 wellingguzman

As per vercel/serve-handler#45, it should've been fixed in latest version of serve (11.3.2, which uses serve-handler 6.1.3, which includes mentioned PR). But I'm getting the following error

$ serve
INFO: Discovered configuration in `serve.json`
ERROR: The configuration you provided is wrong:
should be string
{"type":"string"}
serve.json
{
	"headers": [
		{
			"source": "**/*.js.br",
			"headers": [
				{ "key": "Content-Encoding", "value": "br" },
				{ "key": "Content-Type", "value": "text/javascript" },
				{ "key": "Content-Disposition", "value": null }
			]
		}
	]
}

sidvishnoi avatar Jul 06 '20 12:07 sidvishnoi

@sidvishnoi I noticed they implemented a schema validation which doesn't allow null. Hopefully https://github.com/vercel/schemas/pull/58 and https://github.com/vercel/serve/pull/629 could solve this problem.

It requires to upgrade ajv and update the instance to allow null values.

wellingguzman avatar Sep 01 '20 20:09 wellingguzman

I'm also having trouble with not being able to remove the HTTP Header.

Currently, because Vercel automatically sets the Content-Disposition header, so I couldn't specify the file name as the download attribute of the tag.

juyuwol avatar Aug 23 '22 14:08 juyuwol

hi, using null is returning a deployment fail error 'headers[0].headers[1].value' should be string

sunlee-newyork avatar Jan 05 '23 15:01 sunlee-newyork

Same problem as @sunlee-newyork

JoaquinPiersigilli avatar Jan 12 '24 20:01 JoaquinPiersigilli