为什么不强制请求使用https而不是http(Heroku,Spring Boot)?

为什么不强制请求使用https而不是http(Heroku,Spring Boot)?,spring,spring-boot,heroku,https,Spring,Spring Boot,Heroku,Https,我正在开发部署在Heroku上的Spring Boot应用程序。我想让它成为https,我有证书和所有这些,因为Heroku是付费的,一切都是自动管理的。但我的应用程序可以通过https和http打开,我只想强制使用https。我在互联网上找到了许多文章,我发现我需要在我的应用程序中更改代码,我已经做到了: @Override protected void configure(HttpSecurity http) throws Exception { http.cor

我正在开发部署在Heroku上的Spring Boot应用程序。我想让它成为https,我有证书和所有这些,因为Heroku是付费的,一切都是自动管理的。但我的应用程序可以通过https和http打开,我只想强制使用https。我在互联网上找到了许多文章,我发现我需要在我的应用程序中更改代码,我已经做到了:

 @Override
    protected void configure(HttpSecurity http) throws Exception {

        http.cors().and().csrf().disable()
                .authorizeRequests().antMatchers("**/mybrocki").authenticated()
                .and()
                .exceptionHandling().authenticationEntryPoint(entryPoint)
                .and()
                .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS);

        http.addFilterBefore(authenticationTokenFilter(), UsernamePasswordAuthenticationFilter.class);
        http.headers().cacheControl().disable();
        http.requiresChannel()
        .requestMatchers(r -> r.getHeader("X-Forwarded-Proto") != null)
        .requiresSecure();
        

    }
但是,对于某些人,它是通过http打开的,而对于其他人,它是通过https打开的。我不确定我是否需要在代码中添加更多的内容,或者我需要在Heroku上设置一些内容。我该怎么办