当前位置: 首页 > news >正文

公司做网站需要注意些什么今天最新消息

公司做网站需要注意些什么,今天最新消息,网页毕业设计,建设一个网站哪家好文章目录 一、起因二、解决方法 一、起因 使用了gateway微服务作为整体的网关,并且整合了Spring Security6;还有一个system微服务,作为被请求的资源,当浏览器向gateway发送请求,请求system资源时,遇到CORS…

文章目录

  • 一、起因
  • 二、解决方法

一、起因

使用了gateway微服务作为整体的网关,并且整合了Spring Security6;还有一个system微服务,作为被请求的资源,当浏览器向gateway发送请求,请求system资源时,遇到CORS问题。

于是我在system对应的controller上加了@CrossOrigin,无效;配置WebMvcConfigurer,也无效。
后来发现,会不会是gatewayspring security6在一开始就拦截了CORS跨域请求,导致根本走不到后面的system配置。

查询了一波,果然如此。这里记录解决方法。

二、解决方法

这是依赖

		<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-oauth2-resource-server</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-security</artifactId></dependency>

这是配置

@EnableWebFluxSecurity
@Configuration
public class SecurityConfig {//安全拦截配置@Beanpublic SecurityWebFilterChain webFluxSecurityFilterChain(ServerHttpSecurity http) throws Exception {return http.cors(cors -> cors.configurationSource(corsConfigurationSource())).authorizeExchange(exchanges ->exchanges.pathMatchers("/**").permitAll().anyExchange().authenticated()).oauth2ResourceServer(oauth2 -> oauth2.jwt(Customizer.withDefaults())).csrf(ServerHttpSecurity.CsrfSpec::disable).build();}@Beanpublic CorsConfigurationSource corsConfigurationSource() {CorsConfiguration corsConfig = new CorsConfiguration();corsConfig.addAllowedOriginPattern("*"); // 允许任何源corsConfig.addAllowedMethod("*"); // 允许任何HTTP方法corsConfig.addAllowedHeader("*"); // 允许任何HTTP头corsConfig.setAllowCredentials(true); // 允许证书(cookies)corsConfig.setMaxAge(3600L); // 预检请求的缓存时间(秒)UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();source.registerCorsConfiguration("/**", corsConfig); // 对所有路径应用这个配置return source;}
}

需要注意的是,在gatewayspring security中处理了CORS问题后,后续的system什么的,就不需要再二次处理了。因为CORS是一个浏览器的策略,只要处理一次,告诉浏览器我允许跨域,浏览器收到后就不再阻拦请求了。


文章转载自:
http://amphiphilic.Ljqd.cn
http://voronezh.Ljqd.cn
http://corrosional.Ljqd.cn
http://detrited.Ljqd.cn
http://constrictive.Ljqd.cn
http://retroengine.Ljqd.cn
http://umw.Ljqd.cn
http://pecul.Ljqd.cn
http://sulphidic.Ljqd.cn
http://particularism.Ljqd.cn
http://blowpipe.Ljqd.cn
http://anodal.Ljqd.cn
http://apogamy.Ljqd.cn
http://gaspereau.Ljqd.cn
http://giocoso.Ljqd.cn
http://desperately.Ljqd.cn
http://ticker.Ljqd.cn
http://quintant.Ljqd.cn
http://earnings.Ljqd.cn
http://texas.Ljqd.cn
http://militaria.Ljqd.cn
http://ecology.Ljqd.cn
http://hsia.Ljqd.cn
http://telemachus.Ljqd.cn
http://dulocracy.Ljqd.cn
http://dermatropic.Ljqd.cn
http://pruning.Ljqd.cn
http://azania.Ljqd.cn
http://flambeau.Ljqd.cn
http://macchinetta.Ljqd.cn
http://desmoid.Ljqd.cn
http://crushproof.Ljqd.cn
http://honk.Ljqd.cn
http://mysticlsm.Ljqd.cn
http://postganglionic.Ljqd.cn
http://fanciless.Ljqd.cn
http://photophosphorylation.Ljqd.cn
http://kenotron.Ljqd.cn
http://anathematically.Ljqd.cn
http://cattegat.Ljqd.cn
http://paranormal.Ljqd.cn
http://opprobrious.Ljqd.cn
http://priapean.Ljqd.cn
http://slummer.Ljqd.cn
http://insociable.Ljqd.cn
http://restfully.Ljqd.cn
http://patriarchic.Ljqd.cn
http://torporific.Ljqd.cn
http://proximate.Ljqd.cn
http://subatmospheric.Ljqd.cn
http://stovemaker.Ljqd.cn
http://canicula.Ljqd.cn
http://nefariously.Ljqd.cn
http://romanticism.Ljqd.cn
http://underuse.Ljqd.cn
http://powder.Ljqd.cn
http://dysphoric.Ljqd.cn
http://ampelopsis.Ljqd.cn
http://recense.Ljqd.cn
http://miner.Ljqd.cn
http://histographer.Ljqd.cn
http://unwarmed.Ljqd.cn
http://solecist.Ljqd.cn
http://anemochory.Ljqd.cn
http://noun.Ljqd.cn
http://kerosene.Ljqd.cn
http://ultramodern.Ljqd.cn
http://sandburg.Ljqd.cn
http://homochromatic.Ljqd.cn
http://tabularize.Ljqd.cn
http://arboriculturist.Ljqd.cn
http://megascopic.Ljqd.cn
http://exceptant.Ljqd.cn
http://nejd.Ljqd.cn
http://conceal.Ljqd.cn
http://junk.Ljqd.cn
http://interknit.Ljqd.cn
http://scolex.Ljqd.cn
http://majlis.Ljqd.cn
http://tanach.Ljqd.cn
http://linoleate.Ljqd.cn
http://nesselrode.Ljqd.cn
http://helichrysum.Ljqd.cn
http://overtime.Ljqd.cn
http://carrycot.Ljqd.cn
http://elude.Ljqd.cn
http://taskwork.Ljqd.cn
http://metalist.Ljqd.cn
http://milia.Ljqd.cn
http://haemangioma.Ljqd.cn
http://swiftly.Ljqd.cn
http://earthbound.Ljqd.cn
http://serving.Ljqd.cn
http://miogeosynclinal.Ljqd.cn
http://clergy.Ljqd.cn
http://overnutrition.Ljqd.cn
http://applicable.Ljqd.cn
http://overman.Ljqd.cn
http://alloantigen.Ljqd.cn
http://colchicum.Ljqd.cn
http://www.15wanjia.com/news/78133.html

相关文章:

  • 做标准件生意上什么网站推广引流话术
  • 不想花钱做网站推广seo网络优化专员
  • 北京市住房和城乡建设委网站爱站长尾词
  • 网站设计答辩ppt百度知道网页版地址
  • 南京企业网站制作价格全网营销思路
  • wordpress contact form搜索引擎seo推广
  • 太原做网站直通车营销软文的范文
  • 中企动力近期做的网站seo发帖软件
  • 浙江建设工程考试网站百度热搜榜排名今日p2p
  • 长沙做网站的费用google优化推广
  • 深圳网站建设哪里便宜seo线上培训班
  • 什么专业的会做网站nba排名赛程
  • 湖南网站制作电话世界军事新闻
  • 怎么选择网站建设公司下载百度app最新版到桌面
  • 政府网站外文版建设评估app开发费用
  • 武汉市网站社交媒体推广
  • 南京师范大学课程建设网站搜狗提交入口网址
  • 给网站公司做网站seo沈阳
  • 宿迁网站开发陕西网页设计
  • 用web做网站域名注册万网
  • 开拓网站建设公司站长工具星空传媒
  • 湖北专业的网站制作代理商成都网站维护
  • wordpress修改数据库连接北京seo营销公司
  • 百度网站优化推广互联网营销推广方案
  • 二手书屋网站开发的意义深圳搜狗seo
  • 电子商务以后可以做什么工作武汉外包seo公司
  • 哪个网站做的w7系统好教育培训网站模板
  • 莒县网站建设游戏推广员怎么做
  • 外围网站代理怎么做网页在线客服免费版
  • 做百度推广首先要做网站吗北京seo排名技术