Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Build a Simple Dynamic Site with Node.js Handling Routes in Node.js User Route

Jarett sisk
Jarett sisk
7,522 Points

I'm a little confused on why the "request.url" returns a "/". Where does this "/" come from? and why does it exist?

Just Curious. I'm not sure how it correlates with the browser URL.

2 Answers

Michael Hulet
Michael Hulet
47,913 Points

A URL is meant to correlate to a specific file/directory on a server. In fact, if there's a plain, static site at https://hulet.tech (which there is), and I request https://hulet.tech/css/home.css, my browser will go to the root directory (/) of the server located at https://hulet.tech, look in the css directory inside the root directory (/css), and look for a file called home.css inside of that css directory (/css/home.css). Likewise, if I request https://hulet.tech/resume.pdf, my browser will go look in the root directory (/) of the server located at https://hulet.tech, and it will grab a file named resume.pdf, which is inside that root directory

This is all meant to illustrate that the first / is a very important part of the URL, and it represents the root directory of the site, which all of the site's on-server resources are located in, just as it would on a normal computer's filesystem

See my response in this thread:

https://teamtreehouse.com/community/cant-understand-requesturl

Let me know if this helps here