title: How to make endpoints accept only @crossorigin enabled uris in springboot while accessing using resttemplate? Why am i not getting cors error?
body: <p>I have two projects A and B. Both run on different ports A(8080) B(8091). I had enabled <code>cors origin(http://localhost:8090)</code> in project A for endpoint "greeting". Then trying to call "greeting" endpoint from project B using <code>resttemplate</code>. Since cross origin in project A and the calling Project B are from different ports, I am expecting a cors related error. </p>
  
  <p><strong>But I am getting a proper response instead of an error.</strong></p>
  
  <p>I tried in chrome and postman but same result</p>
  
  <pre><code>//Project A
  @RestController
  public class GreetingController {
      @GetMapping("/greeting")
      @CrossOrigin(origins = "https://localhost:8090")
      public String greeting() {
          return "greetingsss";
      }
  }
  
  //Project B
  @RestController
  public class GreetingController {
      @GetMapping("/greeting1")
      public String greeting() {
          final String uri = "http://localhost:8080/greeting";
          RestTemplate restTemplate = new RestTemplate();
          String result = restTemplate.getForObject(uri, String.class);
          return result;
      }
  }
  </code></pre>
  
  <p><strong>Expected Result:</strong> failed to load, no access control allow origin</p>
  
  <p><strong>Actual Result:</strong> greetingsss</p>