Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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,842 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