I am updating my old question.
I have a jhipster application with spring boot and vue. When I am trying to make a request from my vue frontend project I am getting the following error:
Access to XMLHttpRequest at 'http://localhost:8080/api/downloader/' from origin 'http://localhost:9000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
I tried setting my origin from the application.dev.yml like this:
cors:
# Allow Ionic for JHipster by default (* no longer allowed in Spring Boot 2.4+)
allowed-origins: 'http://localhost:9000'
allowed-methods: '*'
allowed-headers: '*'
exposed-headers: 'Authorization,Link,X-Total-Count,X-${jhipster.clientApp.name}-alert,X-${jhipster.clientApp.name}-error,X-${jhipster.clientApp.name}-params'
allow-credentials: true
max-age: 1800
I only changed the alowed-origins part. But I am still getting this error. Then I tried the following inside the SecurityConfigurationClass:
.antMatchers("/api/downloader").permitAll()
I thought this maybe would allow the requests but it did not help. Can someone maybe help me out? How should I fix this error? Even if I start it with production profile where cors is disabled it still gives me the same error. Is it something I have to fix from the frontend side? Because login or something else works.