Express.js res.location() Function Last Updated : 15 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report The res.location() function is used to set the response Location HTTP header to the path parameter which is being specified. Basically, it is used to set the response header. It doesn't end the response, after using it you can write a response body if you want to write. Syntax: res.location( path ) Parameter: path: It refers to the URL which is specified in the Referrer header of the request. Installation of the express module: You can visit the link to Install the express module. You can install this package by using this command. npm install express After installing the express module, you can check your express version in the command prompt using the command. npm version express After that, you can just create a folder and add a file, for example, index.js. To run this file you need to run the following command. node index.js Project Structure: Filename: index.js javascript const express = require('express'); const app = express(); const PORT = 3000; app.get('/', function (req, res) { res.location('https://foundryco.com/our-solutions/events/'); console.log(res.get('location')); // https://foundryco.com/our-solutions/events/ }); app.listen(PORT, function (err) { if (err) console.log(err); console.log("Server listening on PORT", PORT); }); Steps to run the program: Make sure you have installed the express module using the following command: npm install express Run the index.js file using the below command: node index.js Output: Console Output: Server listening on PORT 3000 Browser Output: Now open the browser and go to http://localhost:3000/, now check your console and you will see the following output: Server listening on PORT 3000 https://foundryco.com/our-solutions/events/ Comment More infoAdvertise with us Next Article How to use get parameter in Express.js ? G gouravhammad Follow Improve Article Tags : Web Tech Similar Reads How to use get parameter in Express.js ? Express Js is a web application framework on top of Node.js web server functionality that reduces the complexity of creating a web server. Express provides routing services i.e., how an application endpoint responds based on the requested route and the HTTP request method (GET, POST, PUT, DELETE, UP 2 min read How to use Global functions in Express JS? In this article, we will learn the global function of Express. Express JS is a web application framework for Node JS. This framework runs on the server-side framework. It is a trendy Express JS framework for building scalable web applications. There are many functions available in Express JS that ar 2 min read How to get full URL in Express.js ? Express is a small framework that sits on top of Node.jsâs web server functionality to simplify its APIs and add helpful new features. It makes it easier to organize your applicationâs functionality with middleware and routing. It adds helpful utilities to Node.jsâs HTTP object and it facilitates th 2 min read Express.js req.path Property The req.path property contains the path of the request URL. This property is widely used to get the path part of the incoming request URL. Syntax:req.pathParameter: No parameters. Return Value: String Installation of the express module:You can visit the link to Install the express module. You can in 2 min read Express.js app.locals Property In Express.js, app.locals is an object used to store variables that need to be available throughout the app. These variables can be accessed globally across different routes or middleware and are often used for configuration settings or values that should be sharedWhat is app.locals?app.locals is an 3 min read Express.js req.route Property The req.route property contains the currently-matched route which is a string. Syntax: req.route Parameter: No parameters. Return Value: Object Installation of the express module: You can visit the link to Install the express module. You can install this package by using this command. npm install 2 min read Like