0👍
✅
Sorry, I didn’t enable Cross Origin in my java code. I have enabled now and it’s resolved.
@CrossOrigin(origins = "http://localhost:3000")
1👍
Based on your configuration, I’m assuming you’re using the Nuxt Axios module…
The problem seems to be that you’re importing Axios unnecessarily, thus bypassing your axios
configuration in nuxt.config.js
. The Nuxt Axios module docs describe its usage in components:
export default {
async asyncData({ $axios }) {
const ip = await $axios.$get('http://icanhazip.com')
return { ip }
}
}
Note the destructured parameter $axios
. Use that parameter instead of importing your own instance of axios
(i.e., don’t do import axios from 'axios'
), which is not the same as the one configured by Nuxt. No other imports are needed for $axios
.
Proxy URL
Another problem is that your explicitly requesting the proxy address in the URL, but that should be excluded:
// const { data } = await $axios.get('http://localhost:8080/api/dfc/system/docbases'); // DON'T DO THIS
const { data } = await $axios.get('/api/dfc/system/docbases');
Source:stackexchange.com