Api is working fine with postman but not working in react - node.js

Nodejs api is working fine with postman but while i'm trying it with react i'm getting some errors like message: "Request aborted", name: "AxiosError", code: "ECONNABORTED"
I haven't added the authentication yet in my api so that is not needed i guess.
I tried to send it in various ways even i tried to handle preflight problem of cors but not sure if i handled that or not! the api is working with postman absolutely ok response as expected.

make sure you don't pass credentials query params in you get request. if you have added credentials in your get request replace your http method with post.

Related

How to make post request using SOAP in node.js

I'm using the library SOAP (https://www.npmjs.com/package/soap) to make requests to a wsdl, but I'm getting the error HTTP GET not supported, using SOAPUI or even axios with post method seems to work

axios network error with cors activated still returns error

the link to the code link
I am using axios and nodejs.
All routes work and give a response except one. which returns Network error.
that route is /api/ads/myads.
The route works on its own but when used with redux actions it doesn't
The network tab says that this request was blocked.
So I tried to add cors but that didn't solve the issue.
The file in question is .../actions/adActions this one is producing the error while others don't
I will be uploading the code in a minute
This turned out to be my adblocker thinking this was actual ads

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.

POST method not working but GET method working when using CORS Node js

I want to POST the data from body to mongodb but when i use CORS then i am not able to post the data , GET method in working. What configuration we have to make in CORS middleware
This error and resolution came up as the first result of my google query using your error message and expressjs Cannot POST / error using express

How to preserve CORS response headers when throwing exception from a service

I am using ServiceStack to build a RESTful API as a backend to a single-page, ajax heavy app.
I have CORS properly configured and everything works as expected.
Some of my services require authorization and throw exceptions that result in 403 or 401 status codes when the user is not authorized, has a expired token, etc. So far so good.
The problem is that whenever I throw one of these exceptions, ServiceStack doesn't include the CORS headers in the response and then the browser refuses to parse it, as it was an ajax call.
Is there a correct way to throw an exception within a service but preserve the CORS headers?
The work around right now is to not throw the exception, set the headers manually and call response.End(). Just think there might be a better way.

Resources