I am working with Ionic 3 app. Backend for my app is Odoo v11. When connecting my mobile app with Odoo v11 using angular4-odoo-jsonrpc I have to face below error.
Failed to load http://127.0.0.1:8069/web/session/authenticate: Response to the preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8100' is therefore not allowed access.
this is my Code:
import { OdooJsOnProvider } from '../../providers/odoo-js-on/odoo-js-on';
import { Component } from '@angular/core';
import { AlertController, IonicPage, Loading, LoadingController, NavController, NavParams } from 'ionic-angular';
import { UtilsProvider } from "../../providers/utils/utils";
import * as Ng6OdooRPCService from 'angular6-odoo-jsonrpc';
import { OdooRPCService } from 'angular4-odoo-jsonrpc'
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
constructor(
public navCtrl: NavController,
private odooRPC: OdooRPCService
) {
this.odooRPC.init({
odoo_server: "http://127.0.0.1:8069",
http_auth: "admin:admin" // optional
});
this.odooRPC.login('odoo', 'admin', 'admin').then(res => {
console.log('login success');
}).catch(err => {
console.log('login failed', err);
})
}
}