I've found @CrossOrigin to be extremely finicky. You can try using just @CrossOrigin without any parameters as Alexander suggested. Show You can also try adding a custom CorsFilter Bean to the class where you call SpringApplication.run(). That way you've essentially got full control over the filter and can add/remove methods if necessary. Something like this: Caros, Por favor, sabem informar como posso resolver esse problema, parece está havendo um bloqueio para o vue acessar o json, agradeço qualquer ajuda. solução! Depois de algumas pesquisas, descobri que o browser bloqueia o acesso se a url usada no script que roda no browser (javascript) for diferente da url da aplicação, então dependendo da maneira que acessar a aplicação, utilizar no script localhost ou 127.0.0.1 Blz? Usar a mesma base url (domínio) evita o problema de CORS, porém algumas vezes queremos permitir que domínios/hosts diferentes tenham acesso, pra isso definimos uma diretiva de CORS. Não tenho experiencia com spring, mas acredito que você poderia olhar esse site: https://spring.io/guides/gs/rest-service-cors/ How do I enable CORS policy in spring boot?Enable CORS in Controller Method
We need to set the origins for RESTful web service by using @CrossOrigin annotation for the controller method. This @CrossOrigin annotation supports specific REST API, and not for the entire application.
How do you add AccessFor IIS6. Open Internet Information Service (IIS) Manager.. Right click the site you want to enable CORS for and go to Properties.. Change to the HTTP Headers tab.. In the Custom HTTP headers section, click Add.. Enter Access-Control-Allow-Origin as the header name.. Enter * as the header value.. Click Ok twice.. How do I resolve the no AccessOpen your distribution from the CloudFront console. Choose the Behaviors tab. Choose Create Behavior. Or, select an existing behavior, and then choose Edit.. Access-Control-Request-Headers.. Access-Control-Request-Method.. Origin.. How do I fix CORS header AccessIf the server is under your control, add the origin of the requesting site to the set of domains permitted access by adding it to the Access-Control-Allow-Origin header's value. You can also configure a site to allow any site to access it by using the * wildcard. You should only use this for public APIs.
|