I have a Symfony 6.3 application that enables users to produce a report.
They can click a button to download the report, which is working fine, but then if they navigate to another page (or refresh the current page) the user is forced to login again.
Strangely though, this only happens on the production server.
Here is the relevant code returned by the controller:
<code>$writer = new XlsxWriter($this->spreadsheet);
$response = new StreamedResponse(function () use ($writer) {
var_dump("Hello");
//$writer->save('php://output');
});
return $response;
$response->headers->set('Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
$response->headers->set('Content-Disposition', "attachment;filename="Report.xlsx"");
$response->headers->set('Cache-Control', 'max-age=0');
return $response;
</code>
<code>$writer = new XlsxWriter($this->spreadsheet);
$response = new StreamedResponse(function () use ($writer) {
var_dump("Hello");
//$writer->save('php://output');
});
return $response;
$response->headers->set('Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
$response->headers->set('Content-Disposition', "attachment;filename="Report.xlsx"");
$response->headers->set('Cache-Control', 'max-age=0');
return $response;
</code>
$writer = new XlsxWriter($this->spreadsheet);
$response = new StreamedResponse(function () use ($writer) {
var_dump("Hello");
//$writer->save('php://output');
});
return $response;
$response->headers->set('Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
$response->headers->set('Content-Disposition', "attachment;filename="Report.xlsx"");
$response->headers->set('Cache-Control', 'max-age=0');
return $response;
NB: The report is a spreadsheet, but the same thing happens if the file contains a simple string, as above.
Any ideas would be appreciated.
TIA