当前位置:网站首页>跨域问题解决
跨域问题解决
2022-08-02 03:21:00 【Tom没Cat】
解决方案1
SpringBoot 中添加跨域配置类 CorsConfig
package com.example.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/** * 解决跨域问题 */
@Configuration
public class CorsConfig implements WebMvcConfigurer {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOriginPatterns("*")
.allowedMethods("GET", "HEAD", "POST", "PUT", "DELETE", "OPTIONS")
.allowCredentials(true)
.maxAge(3600)
.allowedHeaders("*");
}
}
边栏推荐
猜你喜欢
随机推荐
分布式领域最重要的一篇论文,到底讲了什么?
MySQL分区表详解
API 低代码开发:接口大师,一套开发、管理和提供接口的产品框架
MySQL两阶段提交串讲
TRICK second bullet
MySQL常见的索引
第十一天&shell脚本
mysql8.0安装教程与配置(最详细)操作简单
浏览器的工作原理(dns域名服务器,tcp握手,ssl/tls安全协议,关键渲染路径,重绘及回流,防抖和节流)
删库后!除了跑路还能干什么?
OD-Model [4]: SSD
mysql中如何查看表是否被锁
MongoDB文档存储
AntV X6制作画板工具(图形,线段,图片上传)
Foundry教程:使用多种方式编写可升级的智能代理合约(下)
(转帖)HashCode总结(2)
2022.7.30 js notes Operators and flow controllers, loops
什么是轮式里程计
CV-Model [4]: MobileNet v3
二维数组实战项目--------《三子棋》