Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9077687
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T19:25:58+00:00 2026-06-16T19:25:58+00:00

We have an web application build using node js (express js), which is behind

  • 0

We have an web application build using node js (express js), which is behind nginx.

For a particular API, we want to have the content-type response header as “text/plain”. For this following code is there in controller.

res.setHeader(‘Content-Type’, ‘text/plain’);
res.send(response);

This works when the server is not behind nginx.
But when the server is behind nginx, the response headers are still ‘application/json’

my nginx configuration is mentioned below:

#kZyguser www-data;
user root;
worker_processes 4;
pid /var/run/nginx.pid;

events {
        worker_connections 20000;
        # multi_accept on;
}

http {

        ##
        # Basic Settings
        ##

        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 65;
        types_hash_max_size 2048;
        # server_tokens off;

        # server_names_hash_bucket_size 64;
        # server_name_in_redirect off;

        include /etc/nginx/mime.types;
        default_type application/octet-stream;

        ##
        # Logging Settings
        ##
        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;

        ##
        # Gzip Settings
        ##

        gzip on;
        gzip_disable "msie6";

        # gzip_vary on;
        # gzip_proxied any;
        # gzip_comp_level 6;
        # gzip_buffers 16 8k;
        # gzip_http_version 1.1;

         gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;



        client_max_body_size '10M';
 ##
        # nginx-naxsi config
        ##
        # Uncomment it if you installed nginx-naxsi
        ##

        #include /etc/nginx/naxsi_core.rules;

        ##
        # nginx-passenger config
        ##
        # Uncomment it if you installed nginx-passenger
        ##

        #passenger_root /usr;
        #passenger_ruby /usr/bin/ruby;

        ##
        # Virtual Host Configs
        ##

        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;

       server{
             location / {
              proxy_pass_header text-plain; 
                        }
             }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T19:25:59+00:00Added an answer on June 16, 2026 at 7:25 pm

    Nginx configuration are ok. But still you can’t solve this problem because nginx defines MIME type according to your response from controller so, please serialize your json data before sending response. example.

    res.setHeader('Content-Type', 'text/plain'); res.send(response);
    res.send(JSON.stringify(result));
    

    now yr response header will come as ‘text/plain’. and it works for me.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web application I want to deploy via Web Deploy, using Build
I'm using Node.js + Express to build a web application, and I find the
I have build a web application which shows the list of customers using datalist
I am using Maven 3 to build my project. I have a web application
I have a dilemma. Here is my set-up: ASP.NET/NET 3.5 web application build using
I have a classic 3-tier web application build with MySQL and Tomcat. I want
I have a web application build using classic ASP and VB. How do I
We have been using a web application framework to build apps that need to
I am using Spring MVC to build my web application, and I have a
I want to build an Web-application using jsp/servlets where we will be able to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.