How to disable CORS on API Gateway console? - aws-api-gateway

As I got CORS errors from a website I develop localy, I would like to disable CORS for testing. But there is only an enable switch (which I tried to solve the CORS error).
It is strange as even after manually enabling CORS with Access-Control-Allow-Origin '*', I still get this error:
from origin 'http://localhost:8080' 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
-- added --
I got a bit further in using CORS by hints from this post:
Fail to enable CORS for API Gateway functions
It is not enough to enable CORS, but also to add those extra header information.
Anyway, how to disable the CORS afterwards would still be the question.

Related

Url has been blocked by CORS policy SOAP

I am trying to connect a SOAP service from frontend,
Because of "cors policy blocked" I am using Local Cors Policy which is described here;
"https://www.npmjs.com/package/local-cors-proxy"
I can see that request is getting proxied so no any errors.
"Request Proxied -> /Servis/SiparisServis.svc"
But I am still getting this error;
"Access to XMLHttpRequest at 'https://www.myurl.com/Servis/SiparisServis.svc' (redirected from 'http://localhost:8010/proxy/Servis/SiparisServis.svc') from origin 'http://123.0.0.1:2300' 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."
Any solution ?
I can provide my codes if needed.

Cloudfront not forwarding requests to API Gateway (403 Forbidden)

I have a custom Lambda function that I set up with API Gateway. When invoking the API gateway resource path with Postman the Lambda gets invoked and does what it should. I enabled CORS on the API Gateway and didn't forget to deploy.
On Cloudfront I set up API Gateway as origin. Also I set up a cache behavior that forwards the headers as you can see in the following screenshot.
The response when invoking the endpoint in Cloudfront is the following:
I also tried removing the Host header, which leads to the same error Code but "MissingAuthenticationToken" as error reason. Because I found in the internet, that CORS might be a reason for this, I also tried setting the CORS headers in the response of my Lambda function which also didn't help.
I'm out of ideas right now. Does anyone know how to help? I had nothing but trouble with Cloudfront so far.

I get CORS error when I try to access metadata stored on IPFS

I am trying to fetch the metadata I stored on NFT.storage using axios, but each time I get this error:
Access to XMLHttpRequest at 'ipfs://bafyreib6hf354pwtnwxdmfllegogffvkv2dzsrgbithvjbzzewu757bxay/metadata.json' from origin 'http://127.0.0.1:3000' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, chrome-untrusted, https.
I have solved this issue many times when I used to do web2 development but don't know how to do this here.
You cannot directly access ipfs:// prefixed content from a normal browser or js. Instead, you'd have to access it through a gateway.
Some popular gateways are ipfs.io, pinata, moralis..
This is an example usage of an ipfs gateway:
https://ipfs.io/ipfs/bafyreib6hf354pwtnwxdmfllegogffvkv2dzsrgbithvjbzzewu757bxay/metadata.json
Try making your axios request to this url

Azure CDN Standard Akamai CORS failed

i am using hls/dash for video streaming using azure akamai cdn but every time its getting failed due to CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource
i config cors into my storage account but i am unable to stream video
<Cors>
<CorsRule>
<AllowedOrigins>*</AllowedOrigins>
<AllowedMethods>GET,HEAD,OPTIONS</AllowedMethods>
<AllowedHeaders>*</AllowedHeaders>
<ExposedHeaders>server,range</ExposedHeaders>
<MaxAgeInSeconds>3000</MaxAgeInSeconds>
</CorsRule>
<Cors>
is their any other way to config cors in cdn
Akamai CDN doesn’t have CORS settings and it will pass all headers from the Origin. So, as long as the origin returns CORS headers and CDN Edge Server has not cached the old resource, it will return CORS headers.

CORS issue with RestyGWT client with remote service on JBoss AS 7

I am using RestyGWT to communicate with remote service on JBoss AS7 but getting following error:
OPTIONS http://localhost:8080/remoteService No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://127.0.0.1:8888' is therefore not allowed access.
VM482:81
XMLHttpRequest cannot load http://localhost:8080/remoteService No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://127.0.0.1:8888' is therefore not allowed access.
I have enabled following headers and access control via #OPTIONS in back-end server as:
"Access-Control-Allow-Origin", "*"
"Access-Control-Allow-Methods", "POST, GET, UPDATE, DELETE, OPTIONS"
"Access-Control-Allow-Headers", "content-type,x-http-method-override"
My Client Interface to communicate with the server is as:
#Path("/remoteService")
public interface MonitorMeService extends RestService {
#Path(value="/getBooks")
#GET
#Consumes(MediaType.APPLICATION_JSON)
void getBooks(MethodCallback<List<Books>> callback);
}
Can anyone please tell what i am missing? What CORS handling i am missing?
I was using CORS successfully with RestyGWT until I hit a wall trying to get session cookies to work properly. I use Play framework on the server and the browser was not cooperating with the set-cookie header response to CORS moderated interactions.
I found out that I could completely dispense with all the CORS directives (and also no longer require the use of JSONP) by moving to a simple reverse proxy setup on the server.
This made everything simpler and the cookies work properly now.
If you are interested in more details, please respond to this - I'll be happy to post more details. thanks. JR
Apart from the OPTION, you have to set the Access-Control-Allow-Origin header also for other methods: POST, GET, etc
[EDIT]
I've never used restyGwt, so I dont know how to configure restyGwt servlets to set headers, but I use this filter I wrote sometime ago when I want to configure CORS in my server container. It works for any server servlet (RPC, RF, JSON, etc). I suggest to use this filter instead of dealing with headers in your app.