File tree Expand file tree Collapse file tree 2 files changed +6
-5
lines changed
APIJSON-Java-Server/APIJSON-Eclipse
src/main/java/apijson/demo/server Expand file tree Collapse file tree 2 files changed +6
-5
lines changed Original file line number Diff line number Diff line change 88 <version >0.0.1-SNAPSHOT</version >
99 <packaging >jar</packaging >
1010
11- <name >APIJSON(Idea) </name >
11+ <name >APIJSON</name >
1212 <description >APIJSON Server project using Spring Boot</description >
1313
1414 <parent >
Original file line number Diff line number Diff line change @@ -57,17 +57,18 @@ public static void main(String[] args) throws Exception {
5757 @ Bean
5858 public CorsFilter corsFilter () {
5959 UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource ();
60- source .registerCorsConfiguration ("/**" , buildConfig ()); // 4
60+ source .registerCorsConfiguration ("/**" , buildConfig ());
6161 return new CorsFilter (source );
6262 }
6363 /**CORS跨域配置
6464 * @return
6565 */
6666 private CorsConfiguration buildConfig () {
6767 CorsConfiguration corsConfiguration = new CorsConfiguration ();
68- corsConfiguration .addAllowedOrigin ("*" );
69- corsConfiguration .addAllowedHeader ("*" );
70- corsConfiguration .addAllowedMethod ("*" );
68+ corsConfiguration .addAllowedOrigin ("*" ); //允许的域名或IP地址
69+ corsConfiguration .addAllowedHeader ("*" ); //允许的请求头
70+ corsConfiguration .addAllowedMethod ("*" ); //允许的HTTP请求方法
71+ corsConfiguration .setAllowCredentials (true ); //允许发送跨域凭据,前端Axios存取JSESSIONID必须要
7172 return corsConfiguration ;
7273 }
7374 //支持JavaScript跨域请求 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
You can’t perform that action at this time.
0 commit comments