18 Mart 2015 Çarşamba

Ionic Framework CORS Problemi ve Çözümü

Sizde benim gibi veri alışverişi esnasında CORS hatası alıyorsanız eğer  server tarafında istek yapılan sunucuya alttaki header bilgilerini girin.


header('Access-Control-Allow-Headers: X-ACCESS_TOKEN, Access-Control-Allow-Origin, Authorization, Origin, x-requested-with, Content-Type, Content-Range, Content-Disposition, Content-Description');
header('Access-Control-Allow-Methods: GET, POST, OPTIONS');
header('Access-Control-Allow-Origin: *');




eğer çözüm olmadıysa app.js dosyamıza

.config(function($stateProvider, $urlRouterProvider, $httpProvider) {
    //Enable cross domain calls
    $httpProvider.defaults.useXDomain = true;
    $httpProvider.defaults.headers.common['Access-Control-Allow-Origin'] = '*';
    $httpProvider.defaults.useXDomain = true;
    delete $httpProvider.defaults.headers.common['X-Requested-With'];
})

kod bloğunu ekleyip deneyin.