Angular2和RestApi在同一个容器中

时间:2017-06-05 13:59:22

标签: spring angular

我试图在同一个容器上运行Angular2 WebClient和Spring Rest Api - > tomcat9。

当我在Apache Server上运行Angular2 WebClient(在同一台机器上)时,一切正常。当我尝试在与RestApi相同的容器中运行它时,我收到错误

  

选项"一些网址"净:: ERR_CONNECTION_REFUSED

我试图通过在Spring安全配置中添加frameOptions策略来解决此问题:

protected void configure(HttpSecurity http) throws Exception {
    http.csrf().disable()
            .authorizeRequests()
            .antMatchers(HttpMethod.OPTIONS, SecurityProperties.PATH_PATTERN_ALL).permitAll()
            .antMatchers(SecurityProperties.PATH_PATTERN_ROOT).permitAll()
            .antMatchers(SecurityProperties.PATH_PATTERN_LOGON).authenticated()

           (...)    .and().httpBasic().realmName(SecurityProperties.REALM).authenticationEntryPoint(getBasicAuthEntryPoint())
            .and().sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS)
            .and().exceptionHandling().accessDeniedHandler(accessDeniedHandler);

    http.headers().frameOptions().sameOrigin();
}

0 个答案:

没有答案