# Shared URL Parameters

**URL:** https://discourse.nodered.org/t/shared-url-parameters/36889
**Category:** General
**Created:** [2 December 2020 17:29 UTC](https://discourse.nodered.org/t/shared-url-parameters/36889 "2020-12-02T17:29:45Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Xclone](https://avatars.discourse-cdn.com/v4/letter/x/779978/32.png) [@Xclone](https://discourse.nodered.org/u/Xclone)
#### Post date: [2 December 2020 17:29 UTC](https://discourse.nodered.org/t/shared-url-parameters/36889/1 "2020-12-02T17:29:45Z")

</div>

Not experienced with Node Red and need help doing something which is probably very easy but looks like Mt Everest to me. Want to use browser(s) working locally in Windows 10 local PC that has fields where multiple URL parameters can be filled in:

FOO = 123456

BAR = abc

Then, write URLs with those variables and have them work the same in a browser:

webpage1 dot com/?var1=FOO&var2=BAR  
would send  
webpage1 dot com/?var1=123456&var2=abc

webpage2 , webpage3, etc would use same variables. If I update the fields in a local webpage and refresh browser, would like the new value(s) to be used instead.

Can Node Red be used to do this? Maybe need to implement on a small, inexpensive local web server/"router" (or in the cloud) to modify external addresses sent out with common URL parameters? Not sure?

Any help with this greatly appreciated.

---

<div class="post-metadata">

### Author: ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)
#### Post date: [2 December 2020 22:14 UTC](https://discourse.nodered.org/t/shared-url-parameters/36889/2 "2020-12-02T22:14:22Z")

</div>

This example flow should get you started:

 ![Screenshot 2020-12-02 at 23.14.44](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/b/eb0a0cf45712d1c700fa748fc4beb1688ff3867b.jpeg)

Some explanation;

This will create 2 http endpoints.

The first url: `http://<your-node-red-ip>:1880/set_variables`  
This will present 2 input fields (foo and bar), once you fill it in and submit it, it will store the information into a flow variable.

To get redirected: `http://<your-node-red-ip>:1880/get_variables?var1=foo&var2=bar` (ie matching the fieldnames), it will redirect you to `http://website1.com/?var1=abc1234&var2=dslksh` (with the values coming from the variables).

Check the function node to see what is happening, as a location header will be set based on the variables.

The flow

```auto
[{"id":"2fe7755f.ceb28a","type":"group","z":"a261cacc.0688a","name":"Input form","style":{"label":true},"nodes":["2b82e158.61f07e","8d0b04a8.542d1","ce233bee.f9717","dd2afb80.8b6ff8"],"x":118,"y":199,"w":600,"h":130},{"id":"2b82e158.61f07e","type":"http in","z":"a261cacc.0688a","g":"2fe7755f.ceb28a","name":"","url":"/set_variables","method":"get","upload":false,"swaggerDoc":"","x":234,"y":264,"wires":[["ce233bee.f9717"]]},{"id":"8d0b04a8.542d1","type":"http response","z":"a261cacc.0688a","g":"2fe7755f.ceb28a","name":"","statusCode":"","headers":{},"x":602,"y":240,"wires":[]},{"id":"ce233bee.f9717","type":"template","z":"a261cacc.0688a","g":"2fe7755f.ceb28a","name":"","field":"payload","fieldType":"msg","format":"html","syntax":"mustache","template":"<html>\n <body>\n <form method=\"GET\" >\n FOO:<input type=\"text\" name=\"foo\" /><br/>\n BAR:<input type=\"text\" name=\"bar\" /><br/>\n <input type=\"submit\"/>\n </form>\n </body>\n</html>","output":"str","x":420,"y":264,"wires":[["8d0b04a8.542d1","dd2afb80.8b6ff8"]]},{"id":"dd2afb80.8b6ff8","type":"change","z":"a261cacc.0688a","g":"2fe7755f.ceb28a","name":"set variables","rules":[{"t":"set","p":"params","pt":"flow","to":"req.query","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":622,"y":288,"wires":[[]]},{"id":"ac4de379.e58378","type":"group","z":"a261cacc.0688a","name":"Redirect","style":{"label":true},"nodes":["a95c6fa3.9cf068","2c549988.b846c6","4ca276aa.78cab","3999e6d6.8d29fa"],"x":118,"y":367,"w":604,"h":130},{"id":"a95c6fa3.9cf068","type":"http in","z":"a261cacc.0688a","g":"ac4de379.e58378","name":"","url":"/get_variables","method":"get","upload":false,"swaggerDoc":"","x":234,"y":408,"wires":[["2c549988.b846c6"]]},{"id":"2c549988.b846c6","type":"function","z":"a261cacc.0688a","g":"ac4de379.e58378","name":"","func":"req = msg.req.query\n\nvar1= flow.get(\"params\")[req.var1];\nvar2 = flow.get(\"params\")[req.var2];\n\nurl = \"website1.com/?var1=\"+var1+\"&var2=\"+var2\nmsg.headers = {}\nmsg.headers['Location'] = url\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":420,"y":408,"wires":[["4ca276aa.78cab","3999e6d6.8d29fa"]]},{"id":"4ca276aa.78cab","type":"http response","z":"a261cacc.0688a","g":"ac4de379.e58378","name":"","statusCode":"302","headers":{},"x":636,"y":408,"wires":[]},{"id":"3999e6d6.8d29fa","type":"debug","z":"a261cacc.0688a","g":"ac4de379.e58378","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":626,"y":456,"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: [31 January 2021 22:14 UTC](https://discourse.nodered.org/t/shared-url-parameters/36889/3 "2021-01-31T22:14:23Z")

</div>

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