MyWebConfiguration.java 759 B

12345678910111213141516171819202122232425
  1. package com.webflux.launchadmin.config;
  2. import org.springframework.context.annotation.Bean;
  3. import org.springframework.context.annotation.Configuration;
  4. import org.springframework.web.reactive.config.CorsRegistry;
  5. import org.springframework.web.reactive.config.WebFluxConfigurer;
  6. @Configuration
  7. public class MyWebConfiguration {
  8. //配置底层
  9. @Bean
  10. public WebFluxConfigurer webFluxConfigurer(){
  11. return new WebFluxConfigurer() {
  12. @Override
  13. public void addCorsMappings(CorsRegistry registry) {
  14. registry.addMapping("/**")
  15. .allowedHeaders("*")
  16. .allowedMethods("*")
  17. .allowedOrigins("localhost");
  18. }
  19. };
  20. }
  21. }