HowTo: Set up custom response headers on project levelEdit on GitHub
This HowTo will teach you how to create customer response headers in your Spryker project. We use a header that allows playing full-screen videos in Chrome is used as an example.
The purpose of this article is to illustrate the usage of
ShopApplicationTwigEventSubscriber::createResponse() to create custom headers.
The procedure described in this HowTo is just an example of what you can do with the customer response headers, so you know where to adjust the headers for the other use cases.
Ensure that you have:
- Up-to-date Spryker installation
- Browser to test
- CMS page with the video in your Spryker-based shop
Setting up custom response headers
To set up custom response headers:
- For the video example, change the
CmsControllerof the respective CMS page:
$response = new \Symfony\Component\HttpFoundation\Response(); $response->headers->set('Feature-Policy', 'fullscreen *'); $response->setContent( $this->renderView($localeCmsPageDataTransfer->getTemplatePath(), $viewData) ); return $response;
- Optional: to change the header response globally, edit
$response->headers->set('Feature-Policy', 'fullscreen *');
You should now be able to see the video on the full screen.
For submitting the form