Header/footer conflicting with JSON

Similar to the other thread about Middleware, you could use the same approach. You could create a Middleware that sets the header and footer, then apply that Middleware to routes that need it, and don’t apply it to any routes that don’t need it.