package com.scut.vsp.config.security;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * Created by ASH on 21/04/2017.
 */

@Configuration
@EnableWebMvc
public class WebConfig extends WebMvcConfigurerAdapter {
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/v1/**")
                .allowedOrigins("*")
                .allowedMethods("GET", "POST", "DELETE", "PUT")
                .allowedHeaders("Content-Type", "X-Authorization", "X-Requested-With")
                .allowCredentials(false).maxAge(3600);
    }
}

@@ -47,56 +47,347 @@
 org.
-springframework.context.annotation.Configuration
+apache.catalina.filters.CorsFilter;%0Aimport org.springframework.boot.web.servlet.FilterRegistrationBean;%0Aimport org.springframework.context.annotation.Bean;%0Aimport org.springframework.context.annotation.Configuration;%0Aimport org.springframework.web.cors.CorsConfiguration;%0Aimport org.springframework.web.cors.UrlBasedCorsConfigurationSource
 ;%0Aim
@@ -526,16 +526,91 @@
 WebMvc;%0A
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;%0A
 import o
@@ -782,15 +782,85 @@
 fig 
-extends
+%7B%0A    @Bean%0A    public WebMvcConfigurer corsConfigurer() %7B%0A        return new
  Web
@@ -879,19 +879,29 @@
 rAdapter
+()
  %7B%0A
+        
     @Ove
@@ -906,16 +906,24 @@
 verride%0A
+        
     publ
@@ -967,24 +967,32 @@
 registry) %7B%0A
+        
         regi
@@ -1016,16 +1016,17 @@
 /v1/**%22)
+;
 %0A       
@@ -1034,243 +1034,25 @@
     
-    .allowedOrigins(%22*%22)%0A                .allowedMethods(%22GET%22, %22POST%22, %22DELETE%22, %22PUT%22)%0A                .allowedHeaders(%22Content-Type%22, %22X-Authorization%22, %22X-Requested-With%22)%0A                .allowCredentials(false).maxAge(3600)
+%7D%0A        %7D
 ;%0A    %7D%0A
 %7D%0A
@@ -1049,10 +1049,9 @@
 ;%0A    %7D%0A
+
 %7D
-%0A

添加 CORS 支持