服务器显示数据而不是从一个服务器下载到另一个服务器

I have a PHP with CSV downloadable script and able to download the file in the FIRST server. Now I made a redirection of this file from the FIRST server to the SECOND server and in the second server, it is showing the data instead of downloading.

Here is the full scenario.

from the FIRST server, I am accessing like this. http://first.server/download.php?type=download

from the second server, I am accessing like this. http://second.server/api/download.php?type=download.

Here is the code that I am using in download.php

$timestamp = date("j-n-Y-H-i-s");
$fileName = $timestamp . "_complete.csv";
ob_clean();
ob_start();
ob_end_flush();
ob_end_clean();
header('Pragma: public');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Cache-Control: private', false);
//header('Content-Type: text/csv');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment;filename=' . $fileName);
$fp = fopen('php://output', 'w');

I have added a rewrite rule in the SECOND server .htaccess file.

RewriteRule ^/api/(.*)$ /apicall/callQAapi.php?request=$1 [L,QSA,NC]

Please find below screenshot of the response from server. enter image description here

Can anyone help me out on this to download the data in the SECOND server?