很简单,创建一个配置类即可,如下:

package com.app.gateway.common.config;

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

@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
	
	public void addCorsMappings(CorsRegistry registry) {
		registry.addMapping("/**")
					.allowedOrigins("*")
					.allowedHeaders("*")
					.allowedMethods("*")
					.maxAge(30 * 1000);
	}
	
}

 

相关文章:

  • 2021-08-17
  • 2022-12-23
  • 2021-04-06
  • 2022-12-23
  • 2021-06-11
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-08
  • 2021-09-11
  • 2022-01-01
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案