Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
黄嘉阳
/
iot-platform-server
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
64cb594b
authored
Sep 28, 2023
by
杨伟程
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge branch 'dev' of
http://git.xmmakeit.com/huangjiay/iot-platform-server
into dev
parents
013c6bb8
98150b4c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
0 deletions
server-common/src/main/java/com/makeit/config/global/cors/GlobalCorsConfig.java
server-common/src/main/java/com/makeit/config/global/cors/GlobalCorsConfig.java
0 → 100644
View file @
64cb594b
package
com
.
makeit
.
config
.
global
.
cors
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.web.cors.CorsConfiguration
;
import
org.springframework.web.cors.UrlBasedCorsConfigurationSource
;
import
org.springframework.web.filter.CorsFilter
;
import
java.util.Arrays
;
/**
* @author : willian fu
* @version : 1.0
* 设置跨域
*/
@Configuration
public
class
GlobalCorsConfig
{
// extends WebMvcConfigurerAdapter {
@Bean
public
CorsFilter
corsFilter
()
{
CorsConfiguration
config
=
new
CorsConfiguration
();
config
.
setAllowCredentials
(
true
);
config
.
setAllowedOriginPatterns
(
Arrays
.
asList
(
"*"
));
config
.
addAllowedMethod
(
"OPTIONS"
);
config
.
addAllowedMethod
(
"HEAD"
);
config
.
addAllowedMethod
(
"GET"
);
config
.
addAllowedMethod
(
"PUT"
);
config
.
addAllowedMethod
(
"POST"
);
config
.
addAllowedMethod
(
"DELETE"
);
config
.
addAllowedMethod
(
"PATCH"
);
config
.
addAllowedHeader
(
"*"
);
UrlBasedCorsConfigurationSource
configSource
=
new
UrlBasedCorsConfigurationSource
();
configSource
.
registerCorsConfiguration
(
"/**"
,
config
);
return
new
CorsFilter
(
configSource
);
}
/*@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowCredentials(true)
.allowedMethods("*")
.allowedOrigins("*")
.allowedHeaders("*")
.maxAge(3600 * 5);
}*/
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment