-1

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:8080/index/home. (Reason: CORS header 'Access-Control-Allow-Origin' missing).

client runs in 8000

rest service runs in 8080 and the service has @CrossOrigin(origins = "http://localhost:8000/")

but still not working

Rafi
  • 201
  • 1
  • 2
  • 6
  • Obviously the server doesn's serve rhe URL you try to fetch. – Günter Zöchbauer Apr 24 '16 at 13:26
  • i have checked with the rest client and i do get the response back. It is with the angular2 side, which i'm not sure where i'm making mistake – Rafi Apr 24 '16 at 13:54
  • this is the error 16.04.24 14:55:22 404 GET / [1]
    [1]
    [1]
    [1]
    [1]
    – Rafi Apr 24 '16 at 13:58
  • That doesn't look like an error message (except the `404`). – Günter Zöchbauer Apr 24 '16 at 13:59
  • Can you try to format the error message properly (wrapping in backticks "`"). Please edit your question and add the error message there. Please check again this is exactly the error message. AFAIR a 404 shows also the URL that actually failed. Your comment above doesn't look like an error message. – Günter Zöchbauer Apr 24 '16 at 14:40
  • when it tried to render the the loop the codes takes the each values from the list (ex: #index of indexes), which were it is failing. I dont see it is hitting the server even after adding the cross origin option in the server side – Rafi Apr 24 '16 at 14:48
  • Looks like project configuration issue to me. I can't help you with this because I only use Dart myself and don't know about this topic. – Günter Zöchbauer Apr 24 '16 at 14:49
  • Thanks for your help. – Rafi Apr 24 '16 at 16:40

1 Answers1

0
@Bean
public CorsFilter corsFilter() {
    final UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
    final CorsConfiguration config = new CorsConfiguration();
    config.setAllowCredentials(true);
    config.addAllowedOrigin("*");
    config.addAllowedHeader("*");
    config.addAllowedMethod("OPTIONS");
    config.addAllowedMethod("HEAD");
    config.addAllowedMethod("GET");
    config.addAllowedMethod("PUT");
    config.addAllowedMethod("POST");
    config.addAllowedMethod("DELETE");
    config.addAllowedMethod("PATCH");
    source.registerCorsConfiguration("/**", config);
    return new CorsFilter(source);
}   
Rafi
  • 201
  • 1
  • 2
  • 6