Getting CORS error while calling Dunzo developer API the API base url is https://apis-staging.dunzo.in
my code is
await axios
.get("https://apis-staging.dunzo.in/api/v1/token", {
headers: {
"client-id": "<MY_CLIENT_ID>",
"client-secret": "<MY_CLIENT_SECRET>",
"Accept-Language": "en_US",
"Content-Type": "application/json",
},
})
.then((response) => {
return res.status(200).json(response);
})
.catch((err) => {
console.log("err =====", err);
return res.status(400).json({
error: err,
});
});
THANKS TO KISSU I EDIT THIS POST (THIS IS NOT A PROPER SOLUTION)
You can do this to bypass the CORS which is not recommended. Go to nuxt.config.js file and create something like this:
axios: {
proxy: true
},
proxy: {
'/api': {
target: 'http://back-url:<some-port>/',
pathRewrite: { '^/api': '' }
}
}
Now, you can send requests like this:
this.$axios.get('/api/some-getter-request')