PatchAPI端点通过Swagger返回404,但直接在生产环境中击中405 我已经开发了一个包含补丁端点的Spring Boot应用程序。端点在本地和UAT环境中非常有效,但是在生产环境中存在一个问题:

问题描述 投票:0回答:0

在Swagger UI中可见端点,请求URL是正确的。

  1. 当我尝试通过Swagger击中API时,会导致404误差。

  2. 当我直接从浏览器中击中端点URL时,它将返回不允许错误的405方法。
  3. 当问题发生时,应用程序日志中没有错误日志。
  4. get
  5. post

    端点是可以在生产中可见的。

  6. 我怀疑什么:

    直接从浏览器击中端点时,405错误表明服务器(或反向代理)可能不会配置为处理补丁请求。 STWAGGE中的404错误可能表明该请求未正确到达应用程序,或者是通过中间件或代理配置阻止/重定向的。 获取和发布端点在生产中正常工作的事实表明,该问题特定于处理补丁请求。

  7. 我需要帮助:

为什么补丁端点会出现不同的错误(404个摇摇欲坠,直接浏览器呼叫405)?
    这可能与反向代理或服务器配置有关(例如,nginx不允许补丁请求)?
  • 考虑到没有错误日志,我应该采取哪些其他步骤来调试此问题?
  • 我是我的SecurityConfig文件:
  • import lombok.RequiredArgsConstructor; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configurers.HeadersConfigurer; import org.springframework.security.web.SecurityFilterChain; import org.springframework.security.web.authentication.logout.LogoutFilter; @Configuration @EnableWebSecurity @RequiredArgsConstructor public class SecurityConfig { private final FilterChainExceptionHandler filterChainExceptionHandler; @Bean public SecurityFilterChain defaultSecurityFilterChain(HttpSecurity http) throws Exception { http .csrf(csrf -> csrf.disable()) .headers(headers -> headers .contentSecurityPolicy(csp -> csp .policyDirectives("default-src 'self'; script-src 'self'; style-src 'self'; frame-ancestors 'none';") ) //CSP implementation ) .headers(headers -> headers .frameOptions(HeadersConfigurer.FrameOptionsConfig::deny) // Deny framing to prevent clickjacking ) .addFilterBefore(filterChainExceptionHandler, LogoutFilter.class) .authorizeHttpRequests(requests -> requests .anyRequest().permitAll() ); return http.build(); } }
任何帮助或建议将不胜感激!

    由于我找不到任何解决方案,我将补丁端点转换为发布,他们正在使用Prod。
java spring-boot swagger swagger-ui swagger-2.0
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.