On Monday, January 22, 2018 at 4:57:34 AM UTC-8, yogeshwar khalkar wrote: > > Please help me, > > > When I am try to login from angular 4 app to web2py rest api browser shows > error like > > OPTIONS http://127.0.0.1:8000/csautomation/user/login 405 (METHOD NOT > ALLOWED) > > *AND* > > Failed to load http://127.0.0.1:8000/csautomation/user/login: 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 405. >
Just to clarify, you're supporting your Angular app with a node.js server running on port 4200, right? > > *here is my angular code* > > login(user): Promise<any>{ > let url: string = `${this.BASE_URL}/login`; > return this.http.post(url,user).toPromise(); > } > > *here my web2py api* > > @request.restful() > def login(): > def POST(username, password): > user = auth.login_bare(username, password) > if user: > return json(user.id) > return user > return locals() > > > Thanks for any help > > /dps -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.