# Redirect from post to get

**URL:** <https://discourse.nodered.org/t/redirect-from-post-to-get/9939>\
**Category:** General\
**Created:** [9 April 2019 10:45 UTC](https://discourse.nodered.org/t/redirect-from-post-to-get/9939 "2019-04-09T10:45:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![tukru](https://avatars.discourse-cdn.com/v4/letter/t/f0a364/32.png) [@tukru](https://discourse.nodered.org/u/tukru)\
**Post date:** [9 April 2019 10:45 UTC](https://discourse.nodered.org/t/redirect-from-post-to-get/9939/1 "2019-04-09T10:45:03Z")

</div>

Hi, I am new with node-red.

I have the following URL: (GET) /test/login, (POST) /test/login and (GET) /test/global.  
The problem it's how to go from (POST) /test/login to (GET) /test/global.

I tried the following solution but doesn't work: [this](https://stackoverflow.com/questions/50845797/how-to-make-http-redirect-in-node-red).

Which could be the problem?

Thanks for all!

---

<div class="post-metadata">

**Author:** ![tukru](https://avatars.discourse-cdn.com/v4/letter/t/f0a364/32.png) [@tukru](https://discourse.nodered.org/u/tukru)\
**Post date:** [11 April 2019 09:12 UTC](https://discourse.nodered.org/t/redirect-from-post-to-get/9939/2 "2019-04-11T09:12:33Z")

</div>

Hello again.  
I solved the problem using redirect and without creating a new variable after processing the POST.

Redirect code:

```auto
msg.res.redirect("/test/login");

```

Thanks for all

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [11 April 2019 10:12 UTC](https://discourse.nodered.org/t/redirect-from-post-to-get/9939/3 "2019-04-11T10:12:14Z")

</div>

You should not rely on that working in the long term. msg.res.redirect is an internal function that we really shouldn't expose.

There's no reason not to do this properly as per the stack overflow answer.

---

<div class="post-metadata">

**Author:** ![tukru](https://avatars.discourse-cdn.com/v4/letter/t/f0a364/32.png) [@tukru](https://discourse.nodered.org/u/tukru)\
**Post date:** [11 April 2019 11:36 UTC](https://discourse.nodered.org/t/redirect-from-post-to-get/9939/4 "2019-04-11T11:36:43Z")

</div>

The problem I have using stack overflow answer it's that it takes long time thinking and doesn't load the page.

These are my nodes:

```auto
[{"id":"1b0b4d38.437b6b","type":"http in","z":"49b70d91.d2841c","name":"","url":"/test/login","method":"get","upload":false,"swaggerDoc":"","x":230,"y":140,"wires":[["c9791a3c.1c6cd"]]},{"id":"c9791a3c.1c6cd","type":"template","z":"49b70d91.d2841c","name":"","field":"payload","fieldType":"msg","format":"html","syntax":"mustache","template":"<html> \n <head>\n <title>Login</title>\n </head>\n <body class=\"bg-primary\">\n <div class=\"container\">\n <form action=\"/test/login\" method=\"post\">\n <div class=\"row\">\n <label for=\"username\" class=\"offset-md-3 col-md-2 text-light\">Username</label>\n <input type=\"text\" name=\"username\" id=\"\" value=\"\" class=\"col-md-4 bg-transparent\" />\n </div>\n <div class=\"row\">\n <label for=\"password\" class=\"offset-md-3 col-md-2 text-light\">PW</label>\n <input type=\"password\" name=\"password\" id=\"password\" value=\"\" class=\"col-md-4 bg-transparent\"/>\n </div>\n <div class=\"row\">\n <input type=\"submit\" class=\"col-md-offset-2 col-md-2 text-light bg-transparent\" value=\"Login\"/>\n </div>\n </form>\n </div>\n </body>\n</html>","output":"str","x":428,"y":140,"wires":[["f1a3bfc6.bc8e7"]]},{"id":"f1a3bfc6.bc8e7","type":"http response","z":"49b70d91.d2841c","name":"","statusCode":"","headers":{},"x":603,"y":141,"wires":[]},{"id":"82038dad.f03d2","type":"http in","z":"49b70d91.d2841c","name":"","url":"/test/login","method":"post","upload":false,"swaggerDoc":"","x":218,"y":203,"wires":[["88f91e9c.9eb868"]]},{"id":"a575af84.f2ec28","type":"http in","z":"49b70d91.d2841c","name":"","url":"/test/global","method":"get","upload":false,"swaggerDoc":"","x":217,"y":259,"wires":[["1abb80bf.477607"]]},{"id":"1abb80bf.477607","type":"template","z":"49b70d91.d2841c","name":"","field":"payload","fieldType":"msg","format":"html","syntax":"mustache","template":"<html>\n <head>\n <title>Global</title>\n </head>\n <body>\n <h1>It works</h1>\n </body>\n</html>","output":"str","x":429,"y":259,"wires":[["1f22cc03.0c0044"]]},{"id":"1f22cc03.0c0044","type":"http response","z":"49b70d91.d2841c","name":"","statusCode":"","headers":{},"x":611,"y":261,"wires":[]},{"id":"88f91e9c.9eb868","type":"function","z":"49b70d91.d2841c","name":"Redirect ","func":"//msg.res.redirect(\"/test/global\");\nmsg.statusCode = 303;\nmsg.headers = {\n Location: \"http://192.168.0.1:1880/test/global\"\n}\n//return msg;","outputs":"0","noerr":0,"x":422,"y":202,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [17 February 2020 14:06 UTC](https://discourse.nodered.org/t/redirect-from-post-to-get/9939/5 "2020-02-17T14:06:38Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
