Getting Cross Origin when trying to add g-reCaptcha in angular - angularjs

I am getting this error.
XMLHttpRequest cannot load https://www.google.com/recaptcha/api/siteverify. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:9001' is therefore not allowed access. The response had HTTP status code 405.

This is an extra security step for the server to ensure requests coming from clients are legitimate. Otherwise a client could fake a response and the server would be blindly trusting that the client is a verified human.
Use following google chrome extension:
Google chrome extension

Related

Github pages react app didn`t get response

I have react app what I already deployed to the GitHub Pages.
But now I have a problem: what I am requesting auth status to server and didn`t get any response. What is the problem?
I have this error in console about my requests
has been blocked by CORS policy:
Response to preflight request doesn't pass access control check:
No 'Access-Control-Allow-Origin' header is present on the requested resource
GitHub pages supports CORS since 2015, so you can follow "Fix CORS Error| React Tutorial" which points to:
"Run Chrome browser without CORS" (not recommended, just for testing)
axios/axios issue 853
That last issue mentions:
cURL does not enforce CORS rules. Those rules are enforced by browsers for security purposes.
When you mention that you added the relevant header, I assume you mean you added those headers to the request.
Actually, the header is expected in the response headers from the server, indicating that the resource is allowed to be accessed by other websites directly.
FYI, CORS - Cross Origin Resource Sharing. Since your API does not support it, you have two options -
Use a proxy server on the same domain as your webpage to access 4chan's API or,
Use a proxy server on any other domain, but modify the response to include the necessary headers.

Google Cloud Endpoints v2 enable CORS

I'm trying to support cross-origin resource sharing (CORS) calls on my API written using Google Cloud Endpoints Framework v2 in Python, but I am not able to do it.
According to the documentation, CORS is enabled by default, but I can't make any calls from a different origin using Javascript, I get this:
XMLHttpRequest cannot load https://myapp.appspot.com/_ah/api/apiname/v1/events. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://fiddle.jshell.net' is therefore not allowed access. The response had HTTP status code 500.
I've tried adding response.headers like this SO question does, but it's not working either.
Does anyone know how I can enable CORS in my API?
Thanks!
The SO link you posted mentions that the CORS headers need to be sent by the server.
You have to send the http header: "Access-Control-Allow-Origin" with value of "*" or "your client domain".
You can either send this header from the Extensible Serviceble Proxy (ESP) which is part of the Google Cloud Endpoint, or you can send the http header from your server side api script.
I would recommend sending the header from the webserver, since the ESP may cache the api responses.

Getting CORS error in AngularJS when accessing data form REST URI

XMLHttpRequest cannot load http://hfdvcbapp01.vm.itg.corp.us.shldcorp.com:8180/cnb/cnb/report/summary?Company=IT. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://127.0.0.1:64033' is therefore not allowed access.
I am getting this error when i am trying to load data from json which situated at the server.How can i resolve this.
Access-Control-Allow-Origin header should be set in the response,
if it is not from the same origin of the URL it was sent from, the header should be set from the respone - meaning - the server responding to the request in youre case - http://hfdvcbapp01.vm.itg.corp.us.shldcorp.com:8180,
if the server is under youre control just handle it, if its an outside service you should request this.
Your api is not returning header
Access-Control-Allow-Origin: http://yourdomain.com
to allow specific domain
or
Access-Control-Allow-Origin: *
to allow all
PS. Also make sure that headers are actually there. Pay attention that CORS actually send 2 requests 1 will be OPTIONS, second will be actual request so if you return headers only on GET or POST it wont work. To check it in chrome presss f12, go to network and do you requests make sure that header is there
Read more

Unable to call Restful Service in AngularJs application

I am trying to create a search application in angularjs.However, i am getting the below error . Can someone please help.
AddrBook.html:1 XMLHttpRequest cannot load http://121.242.159.36:6006/AddressBookWS/rest/addressBookService/getCompany/%20%20%20%20%20%20%20%20%20%20JB. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.
Thanks
Srikala
(1)
No 'Access-Control-Allow-Origin' header is present on the requested resource.
You are making a cross domain request and this header must be present on the server's response.
The header should be ...
Access-Control-Allow-Origin: *
To allow any domain to make a request to the server.
This is your problem! If you have control over the server then add the response header. If not then make the request at your backend to circumvent the X-domain policy and then make the data available to your angular app.
...
(2)
Origin 'null' is therefore not allowed access -- This is because you are not setting the Origin header in your HTTP request
You can set default headers for all http requests in your app config.
Although (2) will not fix the issue just an FYI.

Restangular api calls to external getting 'No Access Allowed'

Following Restangular's documentation and includes an example of this:
// GET to http://www.google.com/ You set the URL in this case
Restangular.allUrl('googlers', 'http://www.google.com/').getList();
I am trying to do the same for angel.co
$scope.trial = Restangular.allUrl('googlers', 'https://api.angel.co/1/users/267770').getList();
And keep getting error
XMLHttpRequest cannot load https://api.angel.co/1/users/267770. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8000' is therefore not allowed access.
Any solutions?
The server (api.angel.co) is not responding with Access-Control headers which results in this error.
When sending XHR requests to domains different from the origin domain web browsers are checking if the service allows this. In your case api.angel.co would need to include the header Access-Control-Allow-Origin: * as part of the response (which it does not).
Assuming you cannot change api.angel.co, an alternative would be to build a server-side proxy (e.g. in node.js) which allows Cross-Origin Resource Sharing.
Check out this great article about Cross-Origin Resource Sharing (CORS).

Resources