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 Creating a Basic Template Engine in Node.js Binding Values

all valid usernames returning an error, "Moved Permanently." (???)

hi Andrew Chalkley, et al.,

here is a link to a snap shot of my current workspace, it is using just the code from the downloaded final files for this Build a Simple Dynamic Site with Node.JS course in the Binding Values section (from the downloaded code, "Stage_3_video_3_finish"). i copied the code from the downloaded finished into the workspace.

https://w.trhou.se/d1yrb5gv4g

when running the app.js node server, then running the code in port 3000 in the browser, i get the following error in the HTML for every valid treehouse username, like mine, "faddah," or "chalkers" or "davemcfarland" ā€”

    <div id="error">
      There was an error getting the profile for chalkers. (Moved Permanently)
    </div>

i have no idea why i'm getting this (Moved Permanently) error. does anyone know what this is about?

thanx in advance.

best,

ā€” faddah

 portland, oregon, u.s.a.

4 Answers

Andrew Chalkley
STAFF
Andrew Chalkley
Treehouse Guest Teacher

Change this line:

    var request = http.get("http://teamtreehouse.com/" + username + ".json", function(response) {

to...

    var request = https.get("https://teamtreehouse.com/" + username + ".json", function(response) {

We've moved to HTTPS now :)

hi Andrew Chalkley ,

thanks for answering so promptly. o.k., so i did that. however, when i do that, and i put in one valid user name after the URL, like yours, "chalkers," it works well and returns the profile, but then throws the same node.js trace error on the server that i posted before in this treehouse community forum question ā€”

treehouse:~/workspace$ node app.js                                                    
Server up & running at http://<workspace-url>/, Port 3000.                            
events.js:85                                                                          
      throw er; // Unhandled 'error' event  
            ^                                                                         
Error: write after end                                                                
    at ServerResponse.OutgoingMessage.write (_http_outgoing.js:413:15)                
    at Object.view (/home/treehouse/workspace/renderer.js:19:11)                      
    at Profile.<anonymous> (/home/treehouse/workspace/router.js:43:16)                
    at Profile.emit (events.js:107:17)                                                
    at IncomingMessage.<anonymous> (/home/treehouse/workspace/profile.js:38:36)       
    at IncomingMessage.emit (events.js:129:20)                                        
    at _stream_readable.js:908:16                                                     
    at process._tickCallback (node.js:355:11) 

of course, after that, nothing else works as the server has gone down.

any help with what is going on with this, please? also, none of my css formatting is working, and i've included it in my index.html just like you did. you can see the snapshot of my files here ā€” https://w.trhou.se/d1yrb5gv4g.

also, will this course be updated with the require('https') correction, so others don't run into this issue?

please advise, and thank you again very much for the help.

best,

ā€” faddah

 portland, oregon, u.s.a.
J llama
J llama
12,631 Points

this does nothing... thanks again for some horrible feedback chalks, has been the longest 2 hour course of my life....

Mark DeArmond
Mark DeArmond
15,233 Points

I had the same problem as you Faddah. I even changed the the requires to use 'https'. Now I'm not getting an error in the terminal(console) but, I am getting a "no data received" message on chrome. I'm doing this all locally instead of workspaces so there might be another issue lying around somewhere. I just didn't want to post a new thread if there was already one on the same issue. Here is a link to a screenshot of my issue. Any help would be much appreciated. https://drive.google.com/file/d/0B2OYFGzZOSC-SFo3VXFJLTJieE0/view?usp=sharing

thank you for the reply Mark DeArmond ā€” i see your console shows no error on the node.js server, port 8000, in your screen shot. have you looked at the console/dev tools for the local web page? maybe the clue as to what you're not receiving is there.

my problem is very different. what happens now is i get the JavaScript trace error i show above (^^^^ in my reply to Andrew Chalkley) on the node workspace console if i try and do a look up of more than just one valid username; which, of course, kills everything.

would love to hear some response from someone at treehouse or their web IT staff as to what is going on here. i truly believe the IT folks at treehouse changed some things on the back-end server that makes poor chalker's code not work properly just explode past one look-up of a username.

i also have a support request on all this into treehouse support, so we'll see how it pans out. i've also chatted with @chalkers on twitter about this; he's aware, but very busy right now, but promises to get to it.

best,

ā€” faddah

 portland, oregon, u.s.a.
Mark DeArmond
Mark DeArmond
15,233 Points

P.S. Just to be clear in my screenshot above, chrome shows a bookmark called "BoobTube". I can assure you, that's just what I call YouTube (hence the YouTube icon next to it). Haha. I just realized that might cause confusion to some and wanted to set the record straight. Carry on.

Mark DeArmond
Mark DeArmond
15,233 Points

Thank you Faddah. I realize my current issue isn't the same as your current issue. To clarify, mine started with the same 'https' issue you initially posted about and has cascaded into the "no error" issue I'm having now.

Have you tried downloading the project files and testing the finished code provided to see if it works as desired? If it does indeed work, you can compare lines between your files and the finished ones and maybe find the issue that way. Just a thought. Sometimes those scandalous semicolons are to blame and are an easy fix.

Best of luck!

Mark DeArmond,

yes. i have downloaded the project files and the finished versions and copied that into each file in the workspace. still crashes the node.js server, now even on the final step, the moment i search on any valid user name. very frustrating. waiting to hear on what's going on. i really feel something changed between when Andrew Chalkley finished this module recently and now with the treehouse workspaces with the treehouse web IT staff. something seems to have changed, i'm using clean code, it is still crashing the node.js server. i have no idea why. also, the node.js version they are using in treehouse workspaces is v0.12.4, which is woefully out of date, the current LTS version of node.js is v4.2.4.

i'm hoping they can rectify all of this.

best,

ā€” faddah

 portland, oregon, u.s.a.
Andrew Chalkley
STAFF
Andrew Chalkley
Treehouse Guest Teacher

Hi Faddah Wolf,

I forked your workspace (https://w.trhou.se/d1yrb5gv4g), did the changes I suggested, and visited /chalkers (worked), your username /faddah (worked) I typed in an invalid user and it showed an error in the markup but no stack trace like you're getting.

Have you modified your code from when you took the snapshot?

Also node v0.12.x is still in LTS until April and then it'll be in maintenance 'til December 2016. Check out the talk at Node.js Interactive for context. https://www.youtube.com/watch?v=O28Knn00qYo

Regards
Andrew