Answered by :
<?php header("Access-Control-Allow-Origin: *");
Source : https://enable-cors.org/server_php.html | Last Update : Thu, 06 Aug 20
Answered by : augusto-vicente
Pra usar basta usar a url:
-- https://proxier.now.sh/api?url=https://viacep.com.br/ws/<SEU_CEP_AQUI>/json
Source : https://github.com/filipedeschamps/cep-promise/issues/145#issuecomment-560400856 | Last Update : Mon, 28 Sep 20
Answered by : alive-antelope-5wbcd89vcikl
//Access to XMLHttpRequest at 'http://localhost/[api path].php' from origin 'http://localhost:4200' has been blocked by CORS policy: Request header field content-type is not allowed by Access-Control-Allow-Headers in preflight response.
//The error is simply saying that "Content-Type" is missing from "Access-Control-Allow-Headers".
//Therefore we need to add "Content-Type" to "Access-Control-Allow-Headers".
<?php
header('Access-Control-Allow-Headers: Content-Type');
-----
?>
Source : https://github.com/vercel/micro/issues/415 | Last Update : Sat, 17 Oct 20
Answered by : perfect-platypus-nkkjbmrr1kfk
@Configuration
@EnableWebMvc
public class WebConfig extends WebMvcConfigurerAdapter { @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/api/**") .allowedOrigins("http://domain2.com") .allowedMethods("PUT", "DELETE") .allowedHeaders("header1", "header2", "header3") .exposedHeaders("header1", "header2") .allowCredentials(false).maxAge(3600); }
}
Source : https://stackoverflow.com/questions/35091524/spring-cors-no-access-control-allow-origin-header-is-present | Last Update : Mon, 31 May 21
Answered by : anjali-sharma-gqdoo1uchmep
@CrossOrigin(origins = "http://localhost:4200")
@RestController
@RequestMapping("/api/v1/")
public class EmployeeController {
// ..
}
Source : https://www.javaguides.net/2021/08/angular-crud-example-with-spring-boot.html | Last Update : Tue, 10 Jan 23
Answered by : perfect-platypus-nkkjbmrr1kfk
@Configuration
@EnableWebMvc
public class WebConfig extends WebMvcConfigurerAdapter { @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**"); }
}
Source : https://stackoverflow.com/questions/35091524/spring-cors-no-access-control-allow-origin-header-is-present | Last Update : Mon, 31 May 21