Boubou
1 year ago
27
3
Vue

CORS issues in VUE on Local Machine

Posted 1 year ago by Boubou

Hello,

I have been stuck with this for ages..... I am using Laravel 5.7 with Vue.js Here is my vue method:

methods: {
        fetchCryptoApi: _.debounce(function () {
        this.currencyResults = "Searching..."
        const instance = axios.create({
        headers: {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}
        });

        instance.get('https://min-api.cryptocompare.com/data/pricemulti?fsyms=ETH,DASH,LYM,BAT&tsyms=BTC,ETH,USD,EUR,GBP,JPY,KRW')
             .then(function(reponse){
             this.currencyResults = response.data.ETH
             }
             )
        }, 500),
    }

I keep getting this in the console:

Access to XMLHttpRequest at 'https://min-api.cryptocompare.com/data/pricemulti?fsyms=ETH,DASH,LYM,BAT&tsyms=BTC,ETH,USD,EUR,GBP,JPY,KRW' from origin 'http://vue2.testing:8000' has been blocked by CORS policy: Request header field X-CSRF-TOKEN is not allowed by Access-Control-Allow-Headers in preflight response.

In my laragon server I checked if "LoadModule headers_module modules/mod_headers.so" was enabled and it is.

Any idea what to do please?

Thank you.

Please sign in or create an account to participate in this conversation.