1、跨域问题,报错如下
新建中间件
代码如下
[code]<?phpnamespace App\\Http\\Middleware;use Closure;class CorsMiddleware{/*** Handle an incoming request.** @param \\Illuminate\\Http\\Request $request* @param \\Closure $next* @return mixed*/public function handle($request, Closure $next){return $next($request)->header(\'Access-Control-Allow-Origin\', \'*\')->header(\'Access-Control-Allow-Methods\', \'POST, GET, OPTIONS, PUT, DELETE\')->header(\'Access-Control-Allow-Headers\', \'Content-Type, Accept, Authorization, X-Requested-With\');}}
使用如下:
[code]\'cors\' => \\App\\Http\\Middleware\\CorsMiddleware::class,