Posts

Some Common issues -spring microsevices ,and loging using android app

 Issue 1: http status 403 forbidden environment : Spring boot microservcei and spring cloud api gateway when sending http request , enven if the request deos not require any authintication . Reason: In the security microservice app, In the webSecurity class , the code in the configure method prevent any request that is not comming from a specific ip protected void configure(HttpSecurity http) throws Exception {         http.csrf().disable();         http.authorizeRequests().antMatchers("/**").hasIpAddress(env.getProperty("gateway.ip"))              .and()         .addFilter(getAuthenticationFilter());         http.headers().frameOptions().disable();     } Solution   comment the line "antMatches.... code changed to  protected void configure(HttpSecurity http) throws Exception {    ...

Adding Cors Configuration to sping cloud gateway

 In your Spring cloud gateway project add this class import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.web.cors.CorsConfiguration; import org.springframework.web.cors.reactive.CorsWebFilter; import org.springframework.web.cors.reactive.UrlBasedCorsConfigurationSource; import org.springframework.web.util.pattern.PathPatternParser; @Configuration public class CorsConfig {          @Bean     public CorsWebFilter corsFilter() {         CorsConfiguration config = new CorsConfiguration();         config.addAllowedMethod("*");         config.addAllowedOrigin("*");         config.addAllowedHeader("*");         UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource...

Rabbitmq server is running but management console is not

The management plugin is not enabled by default, you need to run the below command to enable it rabbitmq-plugins enable rabbitmq_management    

Response Headers are not exposed to the client application -Spring boot,Spring microservices

Image
 I had this problem and I want to share its solution I have Angular application that send HTTP requests to the server and the sent process success but the response returns with no headers or at least the default minimum headers.  I need to read the token and some other information from the header. Solution: Response headers are not exposed by default. you must explicitly expose it in your spring boot application, in the WebSecurityConfigurerAdapter class Add this bean to your web security @Bean     public CorsFilter corsFilter() {         final UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();         final CorsConfiguration config = new CorsConfiguration();         config.setAllowCredentials(true);                config.addAllowedOrigin("*");         conf...