globalcors: # 全局跨域处理配置
add-to-simple-url-handler-mapping: true # 解决options请求被拦截的问题
cors-configurations:
'[/**]':
allowed-origins:
- "http://localhost:8090"
- "http://www.qvfan.com"
allowedMethods:
- "GET"
- "POST"
- "DELETE"
- "PUT"
- "OPTIONS"
allowed-headers: "*" # 允许在请求中携带头信息
allowCredentials: true # 是否允许携带cookie
maxAge: 360000 #这次跨域检测的有效期

本文详细介绍了如何在SpringBoot应用中配置全局跨域(CORS),包括允许的源、HTTP方法、头信息、cookie支持和有效期。重点讨论了`add-to-simple-url-handler-mapping`解决options请求拦截的方法。
2304

被折叠的 条评论
为什么被折叠?



