Nodejs redirect to intended URL after login

Because it differs from the industry-standard way of doing. Traditionally it’s the back-end responsible for commanding a redirect, this happened on standard HTML forms (outside Wappler), where upon a form submission the back-end would give a Location header for the browser to redirect to:

<?php
// Do something with $_POST, e.g. check login credentials
// And then redirect browser
header("Location: /dashboard");

On a side-note, unfortunately Wappler Server Connect doesn’t follow redirects, so you have to rely on a Set Value to provide the redirect URL, and consequent Form On Success browser go to step (which is what Ken did, and also what you did as a variation specific to trip_id).

Perhaps I’m being overly cautious, from my early days of web development :slight_smile:

Before Wappler and before SQL prepared statements, user inputs such as $_GET.trip_id needed to be escaped or sanitized to prevent SQL injection or XSS attacks.

You don’t have to worry about any of that anymore, but those that grew with it stick with those fundamentals in mind.

Thanks! Trying to learn here so appreciate your help!

So I have two instances where I need to pass a parameter like this. One is this instance where I’m sharing a link to a specific trip, the other is to a specific tripbit (which in my app is a part of a trip like a hotel, museum, flight, etc). Right now I’m using https://dashboard.triptakers.travel/?trip_id=423 for trips and https://dashboard.triptakers.travel/?tripbit_id=1275 which I agree looks a bit meh. What would be a better way to have these like this…
https://dashboard.triptakers.travel/tripbit_id/1275
https://dashboard.triptakers.travel/trip_id/423
or something else? And any hints on how I would achieve that would be most appreciated!

After that part I should then not show the parameters in the URL but pass them through the Session info and Set Value?

That’s related to Wappler routes, and then you’d use $_PARAM instead of $_GET

Yes! Edit: The Set Value is for the redirect URL only

I lack the time to assist further :slightly_frowning_face:

1 Like

No worries. I very much appreciate your help!

Hi Heather,

I had the same issue. I tried resolving it with; $_SERVER.PATH_INFO+’?’+$_SERVER.QUERY_STRING

This will pass on the query parameters to the URL and redirects the user to that page - same as Ken mentioned above.

I am using NodeJS and it seems to work. However, I am not sure if this is the best practice.

1 Like