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

Cannot GET /style/main.css

I have a problem with my css link I check in the Firefox inspector in the Style Editor the message is Cannot GET /style/main.css

This is the link in the index.html from public folder <link rel="stylesheet" href="/style/main.css" type="text/css">

The route for public folder app.get('/', express.static('public'));

there is something else that I need to configure I see that the scripts have the same problem! :(

2 Answers

Is it in the same directory as your index.html? If not, you need a dot for each level up or down you go to get to this file. For example, for style folder it might would be href="../style/main.css" type="text/css"

Not sure if this is your issue, but Ive had to do this many times...

Thank you for the answer, I don't know why exactly this question is only in JavaScript topic because I opened the question in the "Building a MEAN Application" anyway I found the problem. Since .css files are static files you have to serve them to the clients. It was a miss type in the router file: app.use('/', express.static('public'));

Hope to be useful for somebody with the same problem :)

Have a great day!