-1

I need basic login auth api. And I wrote in methods section. I also define mounted this function.

My code like is.

connectHes(){

                 var session_url = 'url';

                axios.post(session_url, {
                    basicauth: {
                        username: 'username',
                        password: 'password'
                    }},{
                    headers: {
                        'Access-Control-Allow-Origin':'*'
                    }})},

And my console show has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Is it vue.js problem or laravel problem or my api is wrong?

xxx
  • 7
  • 1
  • 2
    CORS is happening not in your vuejs front-end, but instead in your API. Take a look at this related thread: https://stackoverflow.com/questions/54218774/cors-laravel-vuejs – Brandon Bertelsen Jan 04 '22 at 06:40

1 Answers1

-1

you can set a vue.config.js file take in:

module.exports = {
  devServer: {
    // Paths
    assetsSubDirectory: 'static',
    // assetsPublicPath: '/',
    proxy: {
      '/api':{
        target:'http://localhost:8080', // your address
        changeOrigin:true,
        pathRewrite:{
          '^/api': '' // url
        }
      }
      }
      }
    }