lumen 跨域
https://github.com/palanik/lumen-cors
原理设置header 头信息:
$response->header("Access-Control-Allow-Origin","*");
$response->header("Access-Control-Allow-Headers","Content-Type, Content-Length, Accept-Encoding, X-Requested-With, Origin");
$response->header("Access-Control-Allow-Methods","GET, OPTIONS, POST");
$response->header("Access-Control-Allow-Credentials","true");
lumen 路由分发:
Route::get('/user', 'UserController@index');
或
$router->post('/cart','CartController@Cart');
$router->post('/cart[/{id}/{pid}]','CartController@Cart');
$router->get('user2[/{name:[A-Za-z]+}]', function ($name = null) {
return $name;
});