Url has been blocked by CORS policy SOAP - 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.

Related

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

How to disable CORS on API Gateway console?

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.

Getting CORS policy error when trying to authorize a user in keycloak using REST api

I'm trying to authorize a user in Keycloak using REST api.
API call is successful when I am calling the api from POSTMAN, but when trying from angular app I'm getting below error -
Access to XMLHttpRequest at 'http://localhost:8080/auth/realms/realmname/protocol/openid-connect/token' from origin 'http://localhost:4200' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Headers and body for the request is below -

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.

How to inform OAuth2 API clients about missing credentials?

I build a REST API using Vert.x and would like to add OAuth2 authentication.
In my current setup unauthenticated requests will automatically be redirected to the OAuth2 server (keycloak) login page. This seems wrong when dealing with a REST API. Instead I would expect my REST API server to return a 401 and thus let the client deal with the process of getting the access token.
Is there a best practice for this use case? How should unauthenticated requests to protected resources be handled?
When a access token is missing you should return an HTTP 400. If the token is invalid it would have to be HTTP 401 as shown in https://www.rfc-editor.org/rfc/rfc6750#section-3.1:
3.1. Error Codes
When a request fails, the resource server responds using the
appropriate HTTP status code (typically, 400, 401, 403, or 405) and
includes one of the following error codes in the response:
invalid_request
The request is missing a required parameter, includes an
unsupported parameter or parameter value, repeats the same
parameter, uses more than one method for including an access
token, or is otherwise malformed. The resource server SHOULD
respond with the HTTP 400 (Bad Request) status code.
invalid_token
The access token provided is expired, revoked, malformed, or
invalid for other reasons. The resource SHOULD respond with
the HTTP 401 (Unauthorized) status code. The client MAY
request a new access token and retry the protected resource
request.
insufficient_scope
The request requires higher privileges than provided by the
access token. The resource server SHOULD respond with the HTTP
403 (Forbidden) status code and MAY include the "scope"
attribute with the scope necessary to access the protected
resource.
If the request lacks any authentication information (e.g., the
client was unaware that authentication is necessary or attempted
using an unsupported authentication method), the resource server
SHOULD NOT include an error code or other error information.
For example:
HTTP/1.1 401 Unauthorized
WWW-Authenticate: Bearer realm="example"