Spring 云网关 GET api 工作正常但 POST 不正常

Spring cloud gateway GET api is working fine but POST is not

我是 Spring 云和 spring 后端开发的新手。我正在尝试使用 spring 云网关开发一个简单的微服务。

Github 链接到 Discovery Server, Spring Cloud Api Gateway and User micro service。令人惊讶的是,当我在 Postman 中执行 APIs 时,GET API 有效但 POST.

无效

我尝试调试,它在 POST 后没有到达我的控制器。我错过了什么?还是做错了? 任何帮助或建议都会有所帮助。

可能是跨域问题
这是一个例子


import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.reactive.CorsWebFilter;
import org.springframework.web.cors.reactive.UrlBasedCorsConfigurationSource;
import org.springframework.web.util.pattern.PathPatternParser;

/**
 * @author beichenhpy
 * @version 0.0.1
 * @apiNote CorsConfig description:
 * @since 2021/5/9 9:45 下午
 */
@Configuration
public class CorsConfig {
    private static final String ALLOWED_HEADERS = "x-requested-with, authorization, Content-Type, Authorization, credential, X-XSRF-TOKEN,token,username,client";
    private static final String ALLOWED_METHODS = "*";
    private static final String ALLOWED_ORIGIN = "*";
    private static final String ALLOWED_EXPOSE = "*";
    private static final Long MAX_AGE = 18000L;

    @Bean
    public CorsWebFilter corsWebFilter(){
        CorsConfiguration corsConfiguration = new CorsConfiguration();
        corsConfiguration.addAllowedHeader(ALLOWED_HEADERS);
        corsConfiguration.addAllowedMethod(ALLOWED_METHODS);
        corsConfiguration.addAllowedOrigin(ALLOWED_ORIGIN);
        corsConfiguration.addExposedHeader(ALLOWED_EXPOSE);
        corsConfiguration.setMaxAge(MAX_AGE);
        UrlBasedCorsConfigurationSource configurationSource = new UrlBasedCorsConfigurationSource(new PathPatternParser());
        configurationSource.registerCorsConfiguration("/**",corsConfiguration);
        return new CorsWebFilter(configurationSource);
    }

}

找到问题了。 如果其他人有类似的问题。

我错过了 POST API 的路线。谢谢@spencergibb 的提示。