提交 16076fa3 编写于 作者: 街头小贩's avatar 街头小贩

增加/member/home/topic/**的CORS

上级 771c363b
......@@ -27,6 +27,7 @@ import org.springframework.http.MediaType;
import org.springframework.validation.Validator;
import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean;
import org.springframework.web.servlet.config.annotation.ContentNegotiationConfigurer;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
......@@ -63,6 +64,8 @@ public class ThronesFrontConfig implements WebMvcConfigurer {
private String imageBucketDomain;
@Value("${img.bucket.upload.direct}")
private String imageBucketUploadDirect;
@Value("${site.origin.admin}")
private String adminDomain;
//授权访问的拦截器
@Bean
......@@ -163,6 +166,11 @@ public class ThronesFrontConfig implements WebMvcConfigurer {
lvfb.setValidationMessageSource(messageSource());
return lvfb;
}
//To enable CORS for the whole application
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/member/home/topic/**").allowedMethods("GET").allowedOrigins(adminDomain);
}
@Bean
public MessageSource messageSource() {
ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
......
......@@ -718,6 +718,7 @@ public class TopicController {
String imagePath = "/static/img/default.poster.bg.jpg";
try{
Album album = albumService.get(topicObj.getAlbumId()).orElse(null);
//不希望添加水印可以使用ForumEntityIcoDecorder解码封面地址
imagePath = new UploadImagePathConvert(imageIOMeta.getImageBucketDomain(), imageIOMeta.getUploadImageDirectName())
.decode(album.getCoverLink(), ImageDirectoryEnum.DEFAT, scale)
.map(URL::toString)
......
......@@ -12,7 +12,7 @@ web.validate.encode=UTF-8
# applicationContext-admin.xml
jdbc.driverClassName=com.mysql.cj.jdbc.Driver
# UTC has 8 hour
jdbc.url=jdbc:mysql://127.0.0.1:3306/jforum?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=UTF-8&useSSL=false&zeroDateTimeBehavior=convertToNull
jdbc.url=jdbc:mysql://127.0.0.1:3306/discuz?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=UTF-8&useSSL=false&zeroDateTimeBehavior=convertToNull
jdbc.username=root
jdbc.password=root
jdbc.pool.init=1
......@@ -21,6 +21,8 @@ jdbc.pool.maxActive=20
jdbc.pool.testSql=SELECT 'x'
# web.xml
site.domain=http://center.test.com
# To allowed Cross-Origin for individual MemberHomeController CTL
site.origin.admin=http://admin.test.com
site.defat.avtar=avatar
site.member.freeze=10
site.member.invite=false
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册