Node.js Express - Get http protocol text for request - node.js

In node.js express, if I get a request with an undefined body I would like to log what the http protocol text was so that I can figure out what went wrong. I don't want to flood my logs with every single request made to the server just the one that comes up undefined.

Related

unknown request using express

I installed the nginx(Port 80 connection passed to express 3000 port) and express apps on AWS lightsail. Sometimes an unknown request occurs. like..
GET /_ignition/execute-solution
GET /config/getuser?index=0
GET /owa/auth/logon.aspx?url=https%3a%2f%2f1%2fecp%2f
GET /vendor/phpunit/phpunit/src/Util/PHP/eval-stdin.php
...more...
There were mainly many requests for php. these requests end with a 404 response.
All my API use JWT authentication. Is express safe for these requests? Is there anything I can do?

Express API response directly outputted in browser instead being handled by Nuxt.js

I have an express server that is connected to mongodb. I have a nuxt route for /account under pages directory. I also have a same route in the express server app.use('/account', account) which is handling the requests.
The database model has been set correctly and the response is sent by the server using return res.status(200).json(User) whenever the route is called upon using a get request. I'm also seeing the response being delivered to the browser.
But the problem is the response is being outputted directly in the browser as raw json. Nuxt is not being loaded to handle the response. I haven't setup any $axios data call in the component using asyncdata or fetch yet.
Here's the sample response that i see in the browser
{"email":"sample#example.com","account":"123445667777"}
I'm not sure what the issue is?

Angular with node.js http failure response for unknown url ): 0 unknown error

So let's start with little info in the beginning.
I have nodejs server side app and client app on angular. I send only get requsts to server app just to read data from database. When i started my apps on local machine they were working pretty well. But when i deployed them to server i got such error : (below in screen)
screen with error from angular
So, i added cors support in server app and add Allow Headers. code in nodejs
But it doesn`t help. When i post "GET" request i get my allow headers in response header and my data that i need in body.
screen with response headers in postman
screen with response body in postman
Server - apache. One interesting thing that server app works good with http protocol and when i am using htttps get this errror error with https
But angular works on https.

code HPE_INVALID_METHOD Node js Hapi js

I am trying to make GET request to my API endpoint and when I do the request from another server to the API I see this strange error (on the API):
170125/230803.439, [log,connection,client,error] data: {"bytesParsed":0,"code":"HPE_INVALID_METHOD"}
What does this error mean?
I am sorry I did request on https:// I should have done it on http:// instead

Strange get request in node.js express

My express server send this request, but I don't know which file send it and why it response with 404. Please help me track this down:
GET /sw-import.js?baseURI=http%3A%2F%2Flocalhost%3A3000%2Fbower_components%2Fplatinum-sw%2Fplatinum-sw-register.html&clientsClaim=true&defaultCacheStrategy=networkFirst&importscript=http%3A%2F%2Flocalhost%3A3000%2Fbower_components%2Fplatinum-sw%2Fbootstrap%2Fsw-toolbox-setup.js&importscriptLate=http%3A%2F%2Flocalhost%3A3000%2Fbower_components%2Fplatinum-sw%2Fbootstrap%2Fsw-toolbox-setup.js&precache=&skipWaiting=true&version=1.0 404 6.503 ms - 255
The request means service worker is registered in the scope http://localhost:3000/
You can verify whether it's running by entering chrome://inspect/#service-workers or see the registration using chrome://serviceworker-internals

Resources