content: package org.zeus.config;
  
  import org.zeus.common.LogTrackInterceptor;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.context.annotation.Bean;
  import org.springframework.context.annotation.Configuration;
  import org.springframework.web.cors.CorsConfiguration;
  import org.springframework.web.servlet.config.annotation.CorsRegistry;
  import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
  import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
  
  /**
   * @author: lizhizhong
   * CreatedDate: 2018/11/30.
   */
  @Configuration
  public class CrossOriginConfig implements WebMvcConfigurer {
  
      @Autowired
      private LogTrackInterceptor logInterceptor;
  
      @Override
      public void addInterceptors(InterceptorRegistry registry) {
          registry.addInterceptor(logInterceptor);
      }
  
  
      // During development, webpack server runs on localhost:8080
      // Make the browser happy by returning CORS headers in this case
      @Bean
  //    @Profile("dev")
      public WebMvcConfigurer corsConfigurer() {
          return new WebMvcConfigurer() {
              @Override
              public void addCorsMappings(CorsRegistry registry) {
                  registry.addMapping("/**")
                      .allowedOrigins(CorsConfiguration.ALL)
                      .allowedHeaders(CorsConfiguration.ALL)
                      .allowedMethods(CorsConfiguration.ALL)
                      .allowCredentials(true);
              }
          };
      }
  
  }
  
  