-
-
Notifications
You must be signed in to change notification settings - Fork 242
Open
Labels
Description
Is there an existing issue for this?
- I have searched the existing issues
Current Behavior
If you add headers in fusion or in a middleware to your error pages (Status Code = 404), those headers are not sent to the client.
In a middleware, all code after $next->handle($request); won't be executed.
Other changes (like adding an attribute to the html tag) work as expected.
Expected Behavior
Adding headers to error pages should work through fusion or a middleware.
Steps To Reproduce
-
Add a new document/page on the first level of your site with
uriPathSegment=404(or use existing error page). -
Add the following code to your
Root.fusionfile in your site package:// This part could be skipped, if you have an existing error page error { @context.notfoundDocument = ${q(site).children('[uriPathSegment=404]').get(0)} 4xx { @position = 'start' condition = ${statusCode >= 400 && statusCode < 500 && notfoundDocument} renderer = Neos.Fusion:Renderer { @context.node = ${notfoundDocument} // type = ${q(notfoundDocument).property('_nodeType')} type = 'Vendor.Site:Document.NotFound' renderPath > } } } // IMPORTANT: Add httpResponseHead.headers with a custom header to your error page prototype(Vendor.Site:Document.NotFound) < prototype(Neos.Neos:Page) { httpResponseHead.headers { X-Custom-Header = 'My-Test-Value' } // Optional, just for demo body > body = 'This is my error page' } -
Open browser with an open developer console.
-
Visit any unknown url that will trigger the error page to be rendered and view the returned http headers.
Environment
- Flow: 8.4.2
- Neos: 8.4.2
- PHP: 8.4Anything else?
No response
Reactions are currently unavailable