extracting data from server to client via the http call. error like "Access to XMLHttpRequest at 'file has been blocked by CORS po" - xmlhttprequest

i have fetching data from server to report via the http call. while generating report i am having error in chrome like "zone.js:2990 Access to XMLHttpRequest at 'file:///E:/Report_things/templates%20with%20single%20grade/sample.json' from origin 'http://localhost:4200' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https." so that sometimes i can able to see the data in report. most of the time the data is not coming. whatever it is the error is came in chrome console.if the data got fetched before this error. data was reflected in report. if data got fetched after this error, data is not got rendered in report. please help me to avoid this error.

Related

CSRF and CORS: Why allow the request to happen if we know there will be a cors error?

I am confused by why the cors package allows the request to be processed even if the origin in the request header isn't white-listed. For example, res.status(202).send(await User.find()) returns a response with status code 202, but the data can't be loaded in the Chrome console.
Also, doesn't the browser send preflight OPTIONS requests to know what's allowed; why would it send cookies/credentials along a request with a disallowed origin?
Edit: Tried a post request on jsfiddle and the post request doesn't happen server side. When I said "why the cors package allows" it would be better to say why the browser allows.
CORS is enforced in the browser, not in your server. The server participates in setting headers that the browser can then use to determine whether the request should be allowed or not. But, it is the browser that ultimately decides whether the CORS request satisfies the requirements or not and the result should be passed through to the Javascript in the browser.
Thus, the request is sent to the server, response is received and THEN the browser decides whether the Javascript in the page is allowed to see the result or not.
In some cases where the request is likely to have side effects on the server (based on a set of criteria in the request), the browser will send a pre-flight request to get just the CORS info first.

Fetch request blocked by CORS policy [duplicate]

This question already has answers here:
No 'Access-Control-Allow-Origin' header is present on the requested resource—when trying to get data from a REST API
(26 answers)
Closed 11 months ago.
So I tried to fetch up some Clash Royal data, which works perfectly on Postman, but when I try to use it in my localhost server, this message appears:
This is my Code:
I have tried several headers, all of which do nothing. All solutions on the internet say that I need to change the API settings, which is impossible since I am (obviously) not the owner of the API. Am I doing something wrong?
I expected to get the correct json data and tried several headers, even the one Postman uses.
You can use https://allorigins.win/, just change your URL to https://api.allorigins.win/raw?url=https://api.clashroyale.com/v1/players/%23C8UVYUL90
When the server sends a request, there is no cors check.
Cors error occurred when origin is different in the web browser.
In this situation, your request is from origin: 192.168.2.36:5000 to: https://api.clashroyale.com. Origin is different.
Thus, if clashroyale server is not yours, you cannot put reponse header: Allow-Access-Control-Origin-Header: * for allowing access from 192.168.2.36:5000. So you should process this request in your own server not in your website!

Cypress_- Failed to load resource: net::ERR_EMPTY_RESPONSE

My UI page keeps on loading when I try to perform a click operation. Which in return needs to fetch data using API call in the back end and display it in UI. Attached screenshot for reference.
Access to XMLHttpRequest at 'https://idp2.renault.com/nidp//app/login?target=https%3A%2F%2Fidp2.renault.com%2Fnidp%2Foauth%2Fnam%2Fauthz%3Fresponse_type%3Dcode%26scope%3Dopenid%2Bemail%2Bopenid%2Barca%2Brole-eic-irn65553%26client_id%3Da6a57638-bb90-49b8-b11b-862c9824fa13%26state%3DhGLwfzSpJOUeEw1dk5GOnFfN5L8%26redirect_uri%3Dhttps%3A%2F%2Feic-app2.dev1.applis.renault.fr%3A443%2Fauth%2Foidc%26nonce%3DFiGw4mp9izHujzUrQVgEA7q9SOwUETofvF-5kDVqZqg%26resourceServer%3DIdentityProvider' (redirected from 'https://eic-app2.dev1.applis.renault.fr/assets/i18n/fr.json') from origin 'https://eic-app2.dev1.applis.renault.fr' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource
I had the very same issue with the same error message. My symfony php backend is running locally in docker. XDebug is also installed. Following 2 lines in the backend resolved this issue and I was finally able to login.
touch /var/www/html/xdebug.log
chmod 777 /var/www/html/xdebug.log

Shopify Graphql code returning Error 404. Also noticed that it works on .myshopify domain but not on custom

I do have a question regarding Graphql, i made it work but when we changed our domain from ".myshopify" to "custom" domain, it stopped working, it returns a error 400.
Here's the complete error.
OPTIONS https://testwebsite.myshopify.com/admin/api/graphql.json 400
Access to XMLHttpRequest at 'https://testwebsite.myshopify.com/admin/api/graphql.json' from origin 'https://testwebsite.com.au' 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.
Hope you can give me an answer.
Thank you

Cross Domain Error Worklight Adapter Request

I'm trying to make a GET request from an iPhone app(built on Worklight), to a remote worklight adapter on a remote server.
I have generated the authorization request header using the following
http://remote-url:port/project/authorization/v1/testtoken
However, I keep getting the following cross domain error:
XMLHttpRequest cannot load https://remote-url/project/adapters/call/mq/getAccounts/22. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://myapp-url:port' is therefore not allowed access.
But, when I try do the same GET request using an API tool like Postman, I receive the results no issues on my browser.
First - testtoken is only available from the MobileFirst Studio development environment... you need to take this into consideration.
Second, you're likely using Chrome and Crome disallows CORS by default. Change your browser settings and/or try in a different browser.