新增跨域介绍文章

This commit is contained in:
click33 2023-06-22 20:03:52 +08:00
parent fd5a162c75
commit 4584388c25
4 changed files with 11 additions and 7 deletions

View File

@ -62,10 +62,11 @@ public class SaTokenConfigure implements WebMvcConfigurer {
.setHeader("Access-Control-Allow-Origin", origin)
// 允许所有请求方式
.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE")
// 允许的header参数
.setHeader("Access-Control-Allow-Headers", "x-requested-with,satoken")
// 有效时间
.setHeader("Access-Control-Max-Age", "3600")
// 允许的header参数
.setHeader("Access-Control-Allow-Headers", "x-requested-with,satoken");
;
// 如果是预检请求则立即返回到前端
SaRouter.match(SaHttpMethod.OPTIONS)

View File

@ -52,10 +52,11 @@ public class SaTokenConfigure implements WebMvcConfigurer {
.setHeader("Access-Control-Allow-Origin", "*")
// 允许所有请求方式
.setHeader("Access-Control-Allow-Methods", "*")
// 有效时间
.setHeader("Access-Control-Max-Age", "3600")
// 允许的header参数
.setHeader("Access-Control-Allow-Headers", "*");
.setHeader("Access-Control-Allow-Headers", "*")
// 有效时间
.setHeader("Access-Control-Max-Age", "3600")
;
// 如果是预检请求则立即返回到前端
SaRouter.match(SaHttpMethod.OPTIONS)

View File

@ -1,3 +1,5 @@
# 解决跨域问题
参考:[https://blog.csdn.net/shengzhang_/article/details/119928794](https://blog.csdn.net/shengzhang_/article/details/119928794)
<!-- 参考:[https://blog.csdn.net/shengzhang_/article/details/119928794](https://blog.csdn.net/shengzhang_/article/details/119928794) -->
参考:[https://juejin.cn/post/7247376558367981627](https://juejin.cn/post/7247376558367981627)

View File

@ -350,7 +350,7 @@ String name = StpUtil.getSession().getString("name");
### Q我加了 Sa-Token 的全局过滤器,浏览器报错跨域了怎么办?
参考:[https://blog.csdn.net/shengzhang_/article/details/119928794](https://blog.csdn.net/shengzhang_/article/details/119928794)
参考:[https://juejin.cn/post/7247376558367981627](https://juejin.cn/post/7247376558367981627)
### Q前后端分离项目中前端使用 vue如果不打开 porxy 代理的话,调用 Sa-Token 登录不会将 token 自动注入到 Cookie 中,是因为跨域么?