Trouble with originalURL in Express

Hi everyone,

I’m experimenting a bit with requests and redirects within Express, and I’m new to the framework, so I might be missing something fundamental due to my newness.

In this project Glitch :・゚✧

I have the following code:

app.get("/redirect", function(request,response){
  var fullURL = request.get("host") + "/"+ request.originalURL;
  response.set('location', '');

What I would expect to happen is that request.originalURL would return /redirect, but it’s returning undefined instead.

Is there something I’m missing in order to return the original request’s full URL path?

Hi @aspires,

Its originalUrl and not originalURL! :slight_smile:

Property names are case-sensitive. However, I do understand how you’d make that mistake, acronyms in camel case are a debated topic! (Speaking from personal experience of userId vs userID)



Thank you so much! That indeed did the trick :bowing_man:

1 Like