mstdmstd
6 months ago
2002
6
Vue

In axios request I got has been blocked by CORS policy error

Posted 6 months ago by mstdmstd

Hello, In laravel 5.8 / "vue": "^2.5.17" / "axios": "^0.18" I need to read external data which are read from postman ok : https://imgur.com/a/SRBmK0P

I try to read these data using axios and got error: https://imgur.com/a/o97xLm7

in browse I see details of the request : https://imgur.com/a/EUkyV43

My JS code:

        axios.post(window.REMOTE_SEARCH_WEB, {
            "query": "pc gamers",
            "blogger": false,
            "company": false,
            "influencer": false,
            "article": false,
            "pageId": 1,
            "sort": null,
            "sortOrder": null,
            "searchType": 1,
            "Access-Control-Allow-Origin": this.app_url,
            "Access-Control-Allow-Methods": "POST",
            "Access-Control-Max-Age": 86400,
            "Access-Control-Allow-Headers": "Content-Type, Authorization",
            'Access-Control-Allow-Credentials': 'true'
        }).then((response) => {

where this.app_url is home url of the site the app run at. Googling I found several parameters Access-Control-* must be filled, like in code above, but that did not help me. Can you say how I to fix it?

  1. can it be that a desicion could be from my js code with axios to run action in my control and from there to make request using php/laravel ? If yes, please provide example of such decision...

Thanks!

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