so remove that from the angular end and make the proper changes in the server side code. but it should be received from the API server. I see that you are setting the CORS headers in your request header. If (().equalsIgnoreCase(((HttpServletRequest) req). It is the responsibility of the server side application to control whether the cross origin request should be served or not. chrome. tHeader("Access-Control-Max-Age", "3600") 1)By disabling web security in browser using. tHeader("Access-Control-Allow-Headers", "Authorization, Content-Type") tHeader("Access-Control-Allow-Methods", "POST, PUT, GET, OPTIONS, DELETE") tHeader("Access-Control-Allow-Origin", "*") Cross-origin resource sharing (CORS) is a mechanism that allows resources to be requested from another domain. But none of them worked (Note, with "" referring to the backend, whereas to the Angularhaving access through "").Īn example of how my configuration file looks like is given in the following: server ", ((HttpServletRequest) req).getRequestURL()) In order to solve the problem, I tried different configuration changes within the Nginx server, for example: (1) setting the add_header "Access-Control-Allow-Origin" "", (2) trying similar change while on the proxy-side, proxy_set_header "Access-Control-Allow-Origin" "", etc. The basic requirement is to add Access-Control-Allow-Origin to the response header to specify the origin that is allowed to access resources from the server. Never knew why Keycloak was doing that redirect that caused problem. Origin ANGULAR is therefore not allowed access. While trying to access the data from the backend, I face the error with regard to CORS policy-related, such that on the browser I see the following: ".has been blocked by CORS policy: No "Access-Control-Allow-Origin" header is present." Using Observable from Angular it was: Failed to load AA: Redirect from BB to KEYCLOAK has been blocked by CORS policy: No Access-Control-Allow-Origin header is present on the requested resource. For the backend, I have a dockerized implementation as well. I have built an Angular app and created a docker image, which makes it run on an Nginx server (once it is run).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |