axios network error with cors activated still returns error - node.js

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

Related

Api is working fine with postman but not working in react

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.

Axios not working in AWS Lambda with Google Servers

I am currently experiencing a weird issue.
I use axios in my NodeJS Lambda (AWS) to verify a Google Recaptcha Token.
However, this request to Google via axios.post() takes forever and therefore the Lambda function gets a timeout. (10s)
At first I thought it might be the VPC or the Security Group but no, I commented out the request and sent another request via axios which works.
Only the one via Google does not work. (On my local machine it works of course).
The code I use for posting to Google:
const response = await axios.post(
`https://www.google.com/recaptcha/api/siteverify?secret=${recaptchaSecret}&response=${event.token}`
);
I have already put a try / catch block around it and no errors are printed / catched.
Looking forward to your suggestions.
Thanks.

Express Route.post issue

I use Express for my back-end application. But I have the problem Why there is not any problem on signup route, but when server starts it crashes with following error.
The place it identifies as source of error is signin route. But, what is the difference between signin and signup here. I can't figure out.
Check if your AuthenticationController.signin is defined. Try doing console.log(AuthenticationController.signin) and see if it is defined. I guess most probably typo issue. May be it's AuthenticationController.signIn notice capital I.

I have a route that works when I use localhost:3000, but breaks when I use the live app on gcloud's app engine?

The route uses the DELETE method, which I was able to use in nodejs with the use of the method-override npm package. I can use curl for my GET and POST routes fine, but for the DELETE route in particular, when I change the url from http://localhost:3000/ to http://nameofapp.appspot.com/ in my cURL call, I get a "Error 400 (Bad Request)!!1" in return.
I looked at the route on the dashboard, and it's shown under "client errors" and it shows an error rate of 100% but doesn't give me any more information than that. It is always successful with localhost.
Any ideas??

Syntax error in loopback api gateway

I am following a tutorial :http://strongloop.com/strongblog/node-js-loopback-api-gateway-sample-applications/
and I am getting an error in the code underneath the Proxy heading in the link mentioned above.
Code against the error is
var proxy = require('./middleware/proxy');
var proxyOptions = require('./middleware/proxy/config.json');
app.use(proxy(proxyOptions));
{
"rules": [
"^/api/(.*)$ http://localhost:3002/api/$1 [P]"
]
}
the error message is
is there any thing wrong with the json?
It looks like you just copied and pasted the code from that blog post, but that was not intended to be runnable code, it was just a snippet to illustrate that you could proxy requests. I think the blog post could be a lot more clear (I'll ping the author of it separately). That said, we have an example project which has some actual code that shows you how you might proxy actual requests.
If you're just trying to get a basic example working, then you probably don't even need those lines in your application JS file, so I'd just remove them entirely.
If you do need to proxy requests, take a look at the example project I linked to above, specifically the proxy middleware they have in it.
My Problem is solved the problem was that I did not run the API Server http://localhost:3002 where the request was to be sent. I was only running the proxy server whereas there should be an API Server running also to which the request was to be sent.

Resources