angular2-odoo-jsonrpc
angular2-odoo-jsonrpc copied to clipboard
Access-Control-Allow-Origin
I have this error:
XMLHttpRequest cannot load http://localhost:8069/web/session/authenticate. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:4200' is therefore not allowed access. The response had HTTP status code 400.
---- here's my code --- import { Component } from '@angular/core'; import { OdooRPCService } from 'angular2-odoo-jsonrpc';
@Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.scss'], providers: [OdooRPCService] })
export class AppComponent { title = 'app works!';
constructor(odooRPC: OdooRPCService){ odooRPC.init({ odoo_server: "http://localhost:8069", http_auth: "[email protected]:password" }); odooRPC.login('duniakado', '[email protected]', 'password').then(res => { console.log('login success'); }).catch( err => { console.error('login failed', err); }) }
}
You should enable CORS on server or create an url to proxy_pass to odoo server, for example: /proxy
will proxy_pass to http://localhost:8069
@astronaut1712 I enable CORS on Odoo V10 Server, but it not working. this error: (Reason: missing token ‘authorization’ in CORS header ‘Access-Control-Allow-Headers’ from CORS preflight channel).
Please help me! Thanks,
@anrepham hi you need to add the authorization in the http header, it will be easier if you user nginx or apache as reverse proxy then add the header there
i have the some problem where i make this exact ? https://enable-cors.org/server_nginx.html i how i add the authorization in the hhtp header cause im new please help me