node-red: node-red http request not handling HTTP 302 redirects
What are the steps to reproduce?
I’m forwarding a POST via an Http Request node to a Google published web service on this URL
https://script.google.com/macros/s/AKfycbz1nYYx1ktqDbNSyVtENRFVskv66mvmWQ9LFCiZpQv1CJ4ejfa3/exec
What happens?
I log this response which is a 302 redirect
{"_msgid":"8612b4c7.58b248","payload":"<HTML>\n<HEAD>\n<TITLE>Moved Temporarily</TITLE>\n</HEAD>\n<BODY BGCOLOR=\"#FFFFFF\" TEXT=\"#000000\">\n<H1>Moved Temporarily</H1>\nThe document has moved <A HREF=\"https://script.googleusercontent.com/macros/echo?user_content_key=UhsEJfEQtflP7iWSm7mQs9RVKcklvewkgKr5VR3vvDmV0V_VTrvnTpP5NcEI9EpQg46ajaa2zfFXTFcUGfZCZ7RXcgq0gT4im5_BxDlH2jW0nuo2oDemN9CCS2h10ox_1xSncGQajx_ryfhECjZEnITnVb9GPO3EM94xL0SjiU7mTW5AoyTfRsS7tbwRIWuhsif16vyrYEOEJtrNUoe1H3QY-EXVgzR0&lib=MfTvE3QyAaRnU8ENiiUuZgapk-K1kEKfJ\">here</A>.\n</BODY>\n</HTML>\n","req":{"_readableState":{"objectMode":false,"highWaterMark":16384,"buffer":{"head":null,"tail":null,"length":0},"length":0,"pipes":null,"pipesCount":0,"flowing":true,"ended":true,"endEmitted":true,"reading":false,"sync":false,"needReadable":false,"emittedReadable":false,"readableListening":false,"resumeScheduled":false,"emitClose":true,"destroyed":false,"defaultEncoding":"utf8","awaitDrain":0,"readingMore":false,"decoder":null,"encoding":null},"readable":false,"_events":{},"_eventsCount":0,"socket":"[internal]","connection":"[internal]","httpVersionMajor":1,"httpVersionMinor":1,"httpVersion":"1.1","complete":true,"headers":{"content-type":"application/json; charset=utf-8","content-length":"859","host":"node-red.dynamicdevices.co.uk:1880","connection":"Keep-Alive","accept-encoding":"gzip","user-agent":"okhttp/3.11.0"},"rawHeaders":["Content-Type","application/json; charset=utf-8","Content-Length","859","Host","node-red.dynamicdevices.co.uk:1880","Connection","Keep-Alive","Accept-Encoding","gzip","User-Agent","okhttp/3.11.0"],"trailers":{},"rawTrailers":[],"aborted":false,"upgrade":false,"url":"/mapper","method":"POST","statusCode":null,"statusMessage":null,"client":"[internal]","_consuming":true,"_dumped":false,"baseUrl":"","originalUrl":"/mapper","_parsedUrl":{"protocol":null,"slashes":null,"auth":null,"host":null,"port":null,"hostname":null,"hash":null,"search":null,"query":null,"pathname":"/mapper","path":"/mapper","href":"/mapper","_raw":"/mapper"},"params":{},"query":{},"res":"[internal]","body":{"app_id":"mitems","counter":538,"dev_id":"ttgo1","experiment":"alex_01","hardware_serial":"000050C2C53A7D80","iid":"60909305-6926-4db6-8a04-eec7703c0722","metadata":{"airtime":1974272000,"coding_rate":"4/5","data_rate":"SF12BW125","frequency":868.1,"gateways":[{"altitude":40,"channel":0,"gtw_id":"eui-b827ebfffe8b2956","latitude":53.41026,"longitude":-2.97018,"rf_chain":1,"rssi":-56,"snr":7.8,"time":"2018-12-25T19:02:33.208043Z","timestamp":3490579716}],"modulation":"LORA","time":"2018-12-25T19:02:33.309705731Z"},"mqtt_topic":"mitems/devices/ttgo1/up","payload_fields":{},"payload_raw":"dHRnbyw1MGMyYzUzYTdkODAsMSwzLDA=","phone_alt":65.475341796875,"phone_lat":53.47920075,"phone_loc_acc":10.720000267028809,"phone_loc_provider":"gps","phone_lon":-3.0207173,"phone_time":"2018-12-25T19:02:34Z","port":1,"user_agent":"Android8.0.0 App11:2018.12.16b"},"_body":true,"_passport":{"instance":{"_key":"passport","_strategies":{"session":{"name":"session"},"bearer":{"name":"bearer","_realm":"Users"},"oauth2-client-password":{"name":"oauth2-client-password"},"anon":{"name":"anon"}},"_serializers":[],"_deserializers":[],"_infoTransformers":[],"_framework":{},"_userProperty":"user","_sm":{"_key":"passport"},"strategies":{}}},"route":{"path":"/mapper","stack":[{"name":"cookieParser","keys":[],"regexp":{"fast_star":false,"fast_slash":false},"method":"post"},{"name":"httpMiddleware","keys":[],"regexp":{"fast_star":false,"fast_slash":false},"method":"post"},{"name":"corsHandler","keys":[],"regexp":{"fast_star":false,"fast_slash":false},"method":"post"},{"name":"metricsHandler","keys":[],"regexp":{"fast_star":false,"fast_slash":false},"method":"post"},{"name":"jsonParser","keys":[],"regexp":{"fast_star":false,"fast_slash":false},"method":"post"},{"name":"urlencodedParser","keys":[],"regexp":{"fast_star":false,"fast_slash":false},"method":"post"},{"name":"multipartParser","keys":[],"regexp":{"fast_star":false,"fast_slash":false},"method":"post"},{"name":"rawBodyParser","keys":[],"regexp":{"fast_star":false,"fast_slash":false},"method":"post"},{"name":"<anonymous>","keys":[],"regexp":{"fast_star":false,"fast_slash":false},"method":"post"},{"name":"<anonymous>","keys":[],"regexp":{"fast_star":false,"fast_slash":false},"method":"post"}],"methods":{"post":true}},"cookies":{},"signedCookies":{}},"res":{},"statusCode":302,"headers":{"content-type":"text/html; charset=UTF-8","access-control-allow-origin":"*","cache-control":"no-cache, no-store, max-age=0, must-revalidate","pragma":"no-cache","expires":"Mon, 01 Jan 1990 00:00:00 GMT","date":"Tue, 25 Dec 2018 19:02:35 GMT","location":"https://script.googleusercontent.com/macros/echo?user_content_key=UhsEJfEQtflP7iWSm7mQs9RVKcklvewkgKr5VR3vvDmV0V_VTrvnTpP5NcEI9EpQg46ajaa2zfFXTFcUGfZCZ7RXcgq0gT4im5_BxDlH2jW0nuo2oDemN9CCS2h10ox_1xSncGQajx_ryfhECjZEnITnVb9GPO3EM94xL0SjiU7mTW5AoyTfRsS7tbwRIWuhsif16vyrYEOEJtrNUoe1H3QY-EXVgzR0&lib=MfTvE3QyAaRnU8ENiiUuZgapk-K1kEKfJ","x-content-type-options":"nosniff","x-frame-options":"SAMEORIGIN","x-xss-protection":"1; mode=block","server":"GSE","alt-svc":"quic=\":443\"; ma=2592000; v=\"44,43,39,35\"","accept-ranges":"none","vary":"Accept-Encoding","connection":"close","x-node-red-request-node":"3561f740"},"responseUrl":"https://script.google.com/macros/s/AKfycbz1nYYx1ktqDbNSyVtENRFVskv66mvmWQ9LFCiZpQv1CJ4ejfa3/exec"}
What do you expect to happen?
Looking at the docs I expected the node to follow the redirect. I think it does that for 301?
I tried adding followRedirects=true although I believe it should default to true but this didn’t help.
So am wondering if this is finger trouble on my part or if the node only redirects on 301’s not 302’s?
Please tell us about your environment:
- Node-RED version: v0.19.5
- node.js version: v10.14.2
- npm version: 5.4.1
- Platform/OS: Debian GNU/Linux 9, Linux 4.15.18-7-pve … x86-64
- Browser: Chrome
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 15 (4 by maintainers)
No need to tag individuals … We all get notified when issues are raised.
I would expect it to follow the redirect.
But it’s Christmas day and we’re all off eating too much food to investigate right now.