problems with braintree....



  • Hi everyone, I’m new here.

    I am having problems when trying to connect to the braintree server …
    return this…

    Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin

    *my component*
    **var customer = gateway.customer.create({
            id: "ID Customer",
            firstName: "Customer Name"
          }, function (err, result) {
            alert(result)
            alert(err)
          });**
    
    
    
    *quasar.config.js*
    **devServer: {
        port: 8080,
         open: true,
          headers: {
            'Access-Control-Allow-Origin': '*'
          }
    }**
         
    

    Does anyone have any suggestions?



  • @welitonjose, use proxy:

    devServer: {
      port: 8080,
      open: true,
      proxy: {
        '/api': {
          target: 'http://api.site.com/',
          changeOrigin: true
        },
      }
    },
    

    https://webpack.js.org/configuration/dev-server/#devserver-proxy

    or

    'Access-Control-Allow-Origin': '*'
    


  • @morlz

    Unfortunately, I still can not
    must be doing something wrong

    
    devServer: {
          port: 8080,
          open: true,
          proxy: {
            '/api': {
              target:  'https://api.sandbox.braintreegateway.com',
              changeOrigin: true,
            },
          }
        },