Unable to get the content-disposition header in AngularJS - angularjs

Headers in Response when I log in browser:
log of headers in browser
This is the response I get in Network of browser Developer Console:
headers in browser's network tab
method to download the file:
method to download the file
I'm trying to get content-disposition header which is available in the Response Headers of the POST Request

Related

CORS blocking content only on Firefox and Safari and only onClick()

I'm building a react.js app and I think I have CORS issues but I can't create a server. I'm therefore using a proxy (such as this one https://cors-anywhere.herokuapp.com/${myApiEndpointHere}).
When I'm using Chrome, I'm able to successfully fetch the data. However when I'm using Firefox or Safari, I get these issues listed below. This CORS issue (on Firefox and Safari) seems also to only happen when the scroll is triggered because both for Firefox, Safari and Chrome, I'm able to get my content and log in to the console.
Firefox:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading
the remote resource at
https://res.cloudinary.com/dcpexd0zo/image/upload/v157136216…pes/Capture_d_e%CC%81cran_le_2019-10-17_a%CC%80_21.26.11.jpg.
(Reason: missing token ‘user-agent’ in CORS header
‘Access-Control-Allow-Headers’ from CORS preflight channel).
Cross-Origin Request Blocked: The Same Origin Policy disallows reading
the remote resource at
https://res.cloudinary.com/dcpexd0zo/image/upload/v157136216…pes/Capture_d_e%CC%81cran_le_2019-10-17_a%CC%80_21.26.11.jpg.
(Reason: CORS request did not succeed).
TypeError: NetworkError when attempting to fetch resource.
Safari:
Request header field User-Agent is not allowed by
Access-Control-Allow-Headers.
Fetch API cannot load
https://res.cloudinary.com/dcpexd0zo/image/upload/v1571362166/shapes/Capture_d_e%CC%81cran_le_2019-10-17_a%CC%80_21.26.11.jpg
due to access control checks.
https://res.cloudinary.com/dcpexd0zo/image/upload/v1571362166/shapes/Capture_d_e%CC%81cran_le_2019-10-17_a%CC%80_21.26.11.jpg
Failed to load resource: Request header field User-Agent is not
allowed by Access-Control-Allow-Headers.
Error: The error you provided does not contain a stack trace.
Unhandled Promise Rejection: TypeError: Request header field
User-Agent is not allowed by Access-Control-Allow-Headers.
You should read this: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Headers
And add this header to the response from the proxy server: Access-Control-Allow-Headers: *

Axios failing to downloand an image from s3 due to CORS

When making Axios GET call to retrieve an image from s3 bucket it creates a preflight check using OPTIONS method. Options method response includes the Access-Controll-Allow-Origin: * header with a wild card but the subsequent GET call fails to retrieve the image.
Browser console out put:
Access to XMLHttpRequest at 'https://example.com' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Response headers from the OPTIONS call:
Response headers from the subsequent GET call:
Axios config for the GET call:
Go to bucket permission and configure cors [https://docs.aws.amazon.com/AmazonS3/latest/userguide/ManageCorsUsing.html][s3 cors documentation]

Ionic 4 writing json file blocked by CORS

I'm trying to write a JSON file with my ionic 4 app
I tried the following path:
applicationStorageDirectory
cacheDirectory
dataDirectory
and it giving me the same error:
Access to XMLHttpRequest at 'file:///URL/my_file.json' from origin 'http://localhost' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, https
Here is my code for writing a file:
this.file.writeFile(this.file.dataDirectory + "json_data", 'test.json', JSON.stringify(cars_data), {replace: true});
I want to save the JSON data in the JSON file.

Mixed Content: The page at 'URL' was loaded over HTTPS | AngularJS

Im making an app, where I want to sent $http.get requests to duckduckgo's API but their requests are done over HTTP. Seeing my site is HTTP is get the following error:
angular.js:11756 Mixed Content:
The page at 'URL' was loaded over HTTPS,
but requested an insecure XMLHttpRequest endpoint 'http://api.duckduckgo.com/'.
This request has been blocked; the content must be served over HTTPS.
When I adding the s to my request, I obviously get the following (seeing the CORS isn't setup):
XMLHttpRequest cannot load:
https://api.duckduckgo.com/?q=Undulated%20Tinamou&format=json&pretty=1.
Response to preflight request doesn't pass access control check:
No 'Access-Control-Allow-Origin' header is present on the requested resource.
Origin 'https://URL' is therefore not allowed access. The response had HTTP status code 405.
My question: Is there any was for me to get the json and bypass one of the two stated above?
Edit1:
$http.get('https://api.duckduckgo.com/?q=' + birdname + '&format=json&callback=jsonp&pretty=1').then(function(res){
console.log(res.data);
});
I also tried the following:
$http.jsonp('https://api.duckduckgo.com/?q=' + birdname + '&format=json&callback=jsonp&pretty=1').then(function(res){
console.log(res.data);
});
With the second, I am getting the following error:
Uncaught ReferenceError: json is not defined

XMLHttpRequest cannot load in angular

I couldn't call my service which gives an error
index.html:1 XMLHttpRequest cannot load http://localhost:14652/api/Employee. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:1873' is therefore not allowed access.
What should i do?
Your browser won't let you make this request because the Access-Control-Allow-Origin (necessary for a cross-domain request) is missing in the header of whatever send your api, if you just want to make some tests you can disable it on your browser by launching it with the following flags:
google-chrome --disable-web-security --allow-file-access-from-files
But you should really read this : http://www.eriwen.com/javascript/how-to-cors/ and have cors working on your server

Resources