Skip to content

Commit

Permalink
fix(): spring version will cause allowPrivateWork resolve error
Browse files Browse the repository at this point in the history
  • Loading branch information
Rawven committed Apr 11, 2024
1 parent 81fff53 commit 8be4988
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,13 @@ private CorsMeta createCorsMeta(AnnotationMeta<?> crossOrigin) {
meta.setMaxAge(maxAge != null ? Long.valueOf(maxAge) : null);
String allowCredentials = crossOrigin.getString("allowCredentials");
meta.setAllowCredentials(allowCredentials != null ? Boolean.valueOf(allowCredentials) : null);
String allowPrivateNetwork = crossOrigin.getString("allowPrivateNetwork");
meta.setAllowPrivateNetwork(allowPrivateNetwork != null ? Boolean.valueOf(allowPrivateNetwork) : null);
// Because allowPrivateNetwork does not exist in some spring versions, we need to catch the exception
try {
String allowPrivateNetwork = crossOrigin.getString("allowPrivateNetwork");
meta.setAllowPrivateNetwork(allowPrivateNetwork != null ? Boolean.valueOf(allowPrivateNetwork) : null);
} catch (IllegalArgumentException e) {
meta.setAllowPrivateNetwork(null);
}
return meta;
}
}

0 comments on commit 8be4988

Please sign in to comment.