I have a simple Node/Express route, as follows:
var app = express();
app.get('gettags/:page', function(request,response)
{
var thePage = request.params.page;
...
...
}
The problem I'm having is that if I pass a URL as the parameter, I get a "Cannot GET" error. So, if I call this like:
http://www.mynodeapp.com/gettags/http://www.someurl.com/?withquery=something
I get the "Cannot GET" error. It's been a couple years since I've used Node, so I am probably forgetting something very basic. But I can't get past this, and Googling this issue hasn't turned up anything useful.
Thanks for any help!
Your node code looks fine but for this to work you'll need to URI encode your argument:
var url = 'http://www.mynodeapp.com/gettags/' + encodeURIComponent('http://www.someurl.com/?withquery=something')
//becomes: http://www.mynodeapp.com/gettags/http%3A%2F%2Fwww.someurl.com%2F%3Fwithquery%3Dsomething
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With