CorsConfig.java 744 B

1234567891011121314151617181920212223242526
  1. /**
  2. * Copyright (c) 2016-2019 人人开源 All rights reserved.
  3. * <p>
  4. * https://www.renren.io
  5. * <p>
  6. * 版权所有,侵权必究!
  7. */
  8. package io.renren.config;
  9. import org.springframework.context.annotation.Configuration;
  10. import org.springframework.web.servlet.config.annotation.CorsRegistry;
  11. import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
  12. @Configuration
  13. public class CorsConfig implements WebMvcConfigurer {
  14. @Override
  15. public void addCorsMappings(CorsRegistry registry) {
  16. registry.addMapping("/**")
  17. .allowedOrigins("*")
  18. .allowCredentials(true)
  19. .allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS")
  20. .maxAge(3600);
  21. }
  22. }