Skip to content

Commit

Permalink
Merge pull request #29 from CompPsyUnion/xuanzhi33-patch-1
Browse files Browse the repository at this point in the history
Add CORS
  • Loading branch information
Pleasurecruise authored Nov 15, 2024
2 parents be0166d + c230067 commit efcafcc
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,17 @@ protected void addInterceptors(InterceptorRegistry registry) {
.excludePathPatterns("/student/uniapp/status");
}

// 全局CORS
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOrigins("https://gh.xuanzhi33.cn") // 允许特定域名
.allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS") // 允许的HTTP方法
.allowedHeaders("*") // 允许的请求头
.allowCredentials(false) // 禁用Cookie发送
.maxAge(3600); // 预检请求的缓存时间
}

/**
* 通过knife4j生成接口文档
* @return
Expand Down

0 comments on commit efcafcc

Please sign in to comment.