0

I have this block of code:

// GET - Default (root) app.get('/', (req, res) => { console.log('GET request to "/"..'); res.header('content-type', 'text/html'); return res.end('' + '<h1>Welcome to the <a href="http://throneofli.es/game">Throne of Lies</a> API</h1>' + '<h2>Check back later for public routes.</h2>'); }); 

I tried running this in with Postman:

The results are an average of 21k to 22k ms:

Postman Result Screenshot

Now, sometimes it's speedy, <150ms. However, most of the time, it's not. This is running off an ubuntu16LTS droplet from digitalocean. Is there something weird I'm doing? I'm still new to Node so surely it's in the code. My full code (not that much code) can be found here:

https://github.com/dylanh724/tol-node-public/blob/master/tol/server.js

EDIT 1: I tried using res.send instead of end, but that didn't seem to resolve anything.

5
  • 2
    "22k ms" - Well put. Commented Aug 9, 2016 at 7:30
  • 1
    Sounds more like a problem with name resolution to me... Have you tried with an IP address instead of a hostname? Commented Aug 9, 2016 at 7:43
  • What is the hostname ? On code you have cors with '*.throneoflies.com' and home page you have <Welcome to the <a href="throneofli.es/game"> Commented Aug 9, 2016 at 8:01
  • On an unrelated note, your readme needs updating with regard to obtaining an SSL certificate, since you can obtain free SSL certificates from LetsEncrypt. Commented Aug 9, 2016 at 8:05
  • Ah I didn't try ip. I still have the original version and I'll try later out of curiosity. As for host name, it was throneoflies.com (throneoflie.es is a short url service with tracking). Thanks for the Readme suggestion about ssl will look into it. If you use let's encrypt won't most browsers reject it though since it's not a certified authority? Commented Aug 10, 2016 at 9:31

1 Answer 1

1

Resolved via a workaround : I suspect ordering had something to do with it. I revamped it using express-generator template and going MVC style. No idea why this works and the other doesn't.

PS, why downvoted?

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.