java - Spring boot & security - cors -


according spring boot documentation added bean

 @bean webmvcconfigurer corsconfigurer() {     return new webmvcconfigureradapter() {         @override         public void addcorsmappings(corsregistry registry) {             registry.addmapping("/**").allowedorigins("http://localhost:3000");         }     }; } 

to enable global access localhost:3000 , frontend app. use spring security, if user enter localhost:8080/something redirected login page ( if not logged ) . problem global cors configuration doesn't work.

i have simple controller returns

list<string>  

on other hand have angular service, responsible making request server. looks :

  this.http.get("http://localhost:8080/words", {             headers: new headers({                 'authorization': 'basic ' + btoa('login:password')             })         }).map((res:response) => res.json())         .subscribe(             data => { this.words = data},             err => console.error('error :  ' + err),             () => console.log('done')         ); 

and result can see in google chrome console :

 xmlhttprequest cannot load http://localhost:8080/words. response preflight invalid (redirect) 

how can fix ?


Comments