I have a simple route that calls a method in a controller to generate an RSS feed of news content.
Works great locally but just will not work in production on Laravel Vapor.
public function __invoke()
{
return response()
->view('rss', [
'videos' => Video::all()
])
->header('Content-Type', 'text/xml');
}
What's going wrong on Vapor?
CodePudding user response:
I had to tweak the method
public function __invoke()
{
$xml_version = '<?xml version="1.0" encoding="UTF-8" ?>';
return response()
->view('sitemap', [
'news' => News::all(),
'xml_version' => $xml_version
])
->withHeaders([
'X-Vapor-Base64-Encode' => 'true'
])
->header('Content-Type', 'text/xml');
}
and then in the view
@php
echo $xml_version;
@endphp
...
and we're good.