Http request succeed when using postman, fails when using node.js axios - node.js

I have deployed BeaconCtrl project on heroku, it has a server to server api,
I tried requesting some routes using postman, with the same headers, body and the same route, it responds with 500 internal server error !.
does requesting from server to another server differ from requesting from postman to a server ?

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?

Not getting response with my routes from remote server

I have a node js app running okay locallyenter image description here but when deployed on remote server it is not giving response of the request but only giving response for home page

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.

ReactJS sent GET request, responded with 302 redirect, received CORS error

This is my stack:
Frontend server: Node + ReactJS (f.com)
Backend server (API): Golang (b.com)
I'm doing this in development environment where I use create-react-app to run my frontend server via npm start command. I want to perform authentication using SSO served at sso.example.com/login. Ideally whenever there's a request to the Backend server without proper authorization, it will be responded with HTTP 302 Redirect to the SSO page. So the sequence is:
ReactJS sends GET request to b.com/users
Golang responded with http.Redirect("sso.example.com/login")
ReactJS app gets CORS error from sso.example.com of which I don't have control of adding Access-Control-Allow-Origin:* respond header
How can I redirect my GET request successfully?
In your case, it would be easier to do the redirection in browser on the client side, so you won't have CORS issues (because you are accessing it from the SSO website url directly).
You can either do it with react, which is complicated: Programmatically navigate using react router V4
Or do it with window with plain JavaScript, which is easy but might cause problems with browsing history:
window.location.href = "https://www.example.com";
https://appendto.com/2016/04/javascript-redirect-how-to-redirect-a-web-page-with-javascript/

Resources