package com.wayneleo.quickstart.framework.core.conf;

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

@Configuration
public class CrossOrign extends WebMvcConfigurerAdapter {
    @Override
    public void addCorsMappings( CorsRegistry registry ) {
        registry.addMapping( "/**" );
    }
}

package com.wayneleo.quickstart.framework.core.conf;

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

@Configuration
public class CrossOrign extends WebMvcConfigurerAdapter {
    @Override
    public void addCorsMappings( CorsRegistry registry ) {
        registry.addMapping( "/**" )
                .allowedOrigins( "*" )
                .allowedMethods( "GET", "HEAD", "POST", "PUT", "DELETE", "OPTIONS" )
                .allowCredentials( false )
                .maxAge( 3600 );
    }
}

修复 cors 跨域问题