Removing Response Headers - X-Powered-By & Server


#1

Hello,

I just got off the ground. Read the documentation in whole and have a sample code working. I’m building up on the ground work that has been laid so far. I need to remove the headers X-Powered-By & Server by using the withoutHeader($name) method (Though this can be done at the server level). I’m unable to remove it for some reason. Any help would be very much appreciated.

$app->get ( ‘/selfsignon/finddraft’, function (Request $request, Response $response, array $args)
{
// To get a value from a header
if ($request->hasHeader ( ‘apiKey’ ))
{
$apiKey = $request->getHeaderLine(‘apiKey’);
}

	$userId = $request->getQueryParams()['userid'];


	$query = "SELECT * FROM Music_Drafts WHERE LastUpdatedBy = ' " . $userId ."';";


	$returnString = executeQueryAsJSON ( $GLOBALS ['link'], $query );

	return $response->withoutHeader('X-Powered-By:')->getBody()->write($returnString);



} );

#2

I don’t have direct experience with this, but since those headers are generated by the webserver, perhaps they cannot be removed outside of the webserver config.?.