package com.aaa.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 CorsConfig implements WebMvcConfigurer { @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**") //放行哪些原始域 .allowedOrigins("*") .allowedHeaders("*") // 是否发送Cookie .allowCredentials(true) .allowedMethods("GET", "POST", "OPTIONS", "DELETE", "PUT", "PATCH") .maxAge(3600); } }
前后端连不上?后端这样改
最新推荐文章于 2024-05-07 10:35:12 发布