質問

I run into situation, when i have a feeling, that I'm missing something really obvious...

On client side sits form, that submits to, lets say /submit

on server side I handle it with:

app.post('/submit', function (req, res) {

    'use strict';
    res.redirect(307, "https://ssl.example.com");
});

Everything works, but problem is - I need to add additional data to that post message, that i dont want show to user with hidden inputs.

if I add to that function, lets say

req.body.newthing = "hey, i'm new here!"

its not visible on destination host.

i guess, that express redirect (probably as it should) don't care about what i do to req.body and redirects exactly what client posted.

My question is - is it possible to alter/add req.body, and then redirect client post request to another host as post request?

役に立ちましたか?

解決

There is no way to alter the client's POST request when redirecting in this way, unless of course you want to proxy the request by having the server do the redirect on the client's behalf.

他のヒント

You can use express-session middleware. To learn more about it, go to https://expressjs.com/en/resources/middleware/session.html.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top