php - Routing requests to laravel from angular under Grunt config -


we on project angular , laravel 5 our environment frameworks , implementing using api workflow. using grunt bower configure dependencies project. project structure below.

 --projectdir      |_angulardir        |_start          |_bower_components          |_node_modules          //front end dependencies          |_gruntfile.js      |_public                    //laravel public dir     

we have kept laravel , angular code independent complete mvc architecture , api benefits.

issue:

we start app using grunt serve , application loads first angular route , loads on localhost:9000 configured port.

this has login screen.after entering username , password, call route http://localhost:projectdir/public/login laravel grunt server not have access laravel code localhost:9000 won't work. authenticates user against database.

route::post('login','logincontroller@auth'); 

logincontroller.php

public function auth() {      $rowinput =request::all();     $input = \request::only('customer.email', 'customer.password');     if(auth::attempt(array_get($input, 'customer')))     {        //var_dump(session::all());         return \response::json(['status'=>'success','url'=>$rowinput['customer']['redirecturl']]);      }else {         // return response::json(array('flash' => 'invalid username or password'), 500);         return \response::json(['status'=>'fail','url'=>$rowinput['customer']['redirecturl']]);         // return "fail";     } } 

this route goes , validates user not start session. hence when next route triggered user session absent , user again redirected login form.

if dump session values shows in attempt method, if go previous route,user session not present. how configure routes on server side serve requests , persist session?

request response headers

 remote address:127.0.0.1:80  request url:http://localhost/project_dir/public/user/check  request method:post  status code:200 ok  response headers  view source  access-control-allow-origin:http://localhost:9000  cache-control:no-cache  connection:keep-alive  content-length:4  content-type:text/html; charset=utf-8  date:wed, 29 jul 2015 10:30:33 gmt  keep-alive:timeout=5, max=99  server:apache/2.4.9 (win64) php/5.5.12  set-  cookie:laravel_session=fgdgdgdfgfgdxudrra3e1nxdcl25oekjvslbrpt0ilcj2ywx1zsi6ilvawgf6nmdsv1wvz3ncl1ftvkr5y2j3czlqnukyawdxzljmeg5zk2u2c0lqm2vomey5s000cvwvetbvazbwvfnszxlhzmhwseuxulrymvjide5tce5jm2fdsfsfdsfsfsdfsfsdfsfzin0%3d; expires=wed, 29-jul-2015 12:30:33 gmt; max-age=7200; path=/; domain=http://localhost:9000/;  httponly  vary:origin  x-powered-by:php/5.5.12  request headers  view source  accept:application/json, text/plain, */*  accept-encoding:gzip, deflate  accept-language:en-us,en;q=0.8  cache-control:max-age=0  connection:keep-alive  content-length:0  host:localhost  origin:http://localhost:9000  referer:http://localhost:9000/  user-agent:mozilla/5.0 (windows nt 6.1; wow64) applewebkit/537.36 (khtml,  gecko) chrome/44.0.2403.107 safari/537.36     firephp/4chrome  x-firephp-version:0.0.6  x-wf-max-combined-size:261120 


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -