OAuth2.0 - authentication using GitHub with front-end and back-end running on different servers. CORS error

后端 未结 2 796
花落未央
花落未央 2021-01-07 10:50

I\'m trying to create an application that has front-end and back-end assets separated. For the sake of example, let\'s say that front-end side will eventually be hosted on g

2条回答
  •  迷失自我
    2021-01-07 11:14

    If you are using Spring-Boot you can do this in your spring configuration:

        @Bean
        public WebMvcConfigurer corsConfigurer() {
            return new WebMvcConfigurerAdapter() {
                @Override
                public void addCorsMappings(CorsRegistry registry) {
                    registry.addMapping("/**").allowedOrigins("http://localhost:8080", "http://127.0.0.1:8080");
                }
            };
        }
    

提交回复
热议问题