fastify / point-of-view

Template rendering plugin for Fastify
MIT License
338 stars 86 forks source link

Allow custom `Content-Type` header for Nunjucks #353

Closed smigles closed 1 year ago

smigles commented 1 year ago

Prerequisites

Fastify version

4.2.0

Plugin version

7.1.2

Node.js version

16.13.0

Operating system

Linux

Operating system version (i.e. 20.04, 11.3, 10)

Ubuntu 20.04

Description

Currently, you cannot set a custom Content-Type header if you use Nunjucks template engine. text/html; charset=utf-8 is always sent.

It is similar to #9

Steps to Reproduce

  1. Set Nunjucks as the template engine.
  2. For example write:
    reply.type('application/xml');
    return reply.view('template.njk', { data });
  3. Content-Type response header is text/html; charset=utf-8.

Expected Behavior

Content-Type response header is application/xml; charset=utf-8.

mcollina commented 1 year ago

Thanks for reporting! Would you like to send a Pull Request to address this issue? Remember to add unit tests.