angular2-odoo-jsonrpc icon indicating copy to clipboard operation
angular2-odoo-jsonrpc copied to clipboard

Access-Control-Allow-Origin

Open multisolusiit opened this issue 8 years ago • 6 comments

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); }) }

}

multisolusiit avatar Nov 20 '16 08:11 multisolusiit

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 avatar Feb 23 '17 13:02 astronaut1712

@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 avatar Oct 03 '17 07:10 anrepham

@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

hengkyz avatar Oct 03 '17 07:10 hengkyz

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

ikrape avatar Apr 29 '18 10:04 ikrape