gpt4 book ai didi

spring-boot - 抑制变化 :* response headers generated by Spring Boot

转载 作者:行者123 更新时间:2023-12-02 19:33:43 26 4
gpt4 key购买 nike

我们的 Spring Boot 应用程序生成 Vary 响应 header 用于传输静态资源(顺便说一句,也用于 REST API 调用)。我想抑制它,但我找不到执行此操作的配置选项。

生成以下 header :

Vary:Origin
Vary:Access-Control-Request-Method
Vary:Access-Control-Request-Headers

设置和使用各种缓存属性 spring.resources.cache.* 不成功。 spring.resources.cache 属性在 https://docs.spring.io/spring-boot/docs/current/reference/html/appendix-application-properties.html 中描述。 .

是否有有效的选项来抑制生成这些标题?

最佳答案

Vary header 在 CORS 激活后立即设置。

CORS 可能已被 *Controller 类中的 @CrossOrigin 注释激活。

但是,CORS 也可以通过 SecurityConfig 设置

@Override
protected void configure (HttpSecurity http) throws an exception {
...
http.cors ();
...
}}

另请参阅此问题以获取详细信息:

https://github.com/spring-projects/spring-framework/issues/18378

另请参阅 CORS 规范,因为 Vary header :

https://developer.mozilla.org/de/docs/Web/HTTP/CORS

If the server specifies a single origin rather than the "*" wildcard, then the server should also include Origin in the Vary response header — to indicate to clients that server responses will differ based on the value of the Origin request header.

关于spring-boot - 抑制变化 :* response headers generated by Spring Boot,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61410568/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com