Commit b87383a2 authored by hangjun83's avatar hangjun83

解决跨域问题

parent 31c1b639
......@@ -22,6 +22,7 @@ class Kernel extends ConsoleKernel
* @var array
*/
protected $commands = [
\Laravelista\LumenVendorPublish\VendorPublishCommand::class
];
/**
......
......@@ -84,6 +84,8 @@ $app->configure('enum');
$app->configure('permission');
$app->configure('response');
$app->configure('cors');
$app->alias('cache', \Illuminate\Cache\CacheManager::class);
/*
......@@ -100,6 +102,7 @@ $app->alias('cache', \Illuminate\Cache\CacheManager::class);
$app->middleware([
\Jiannei\Logger\Laravel\Http\Middleware\RequestLog::class,
\Jiannei\Response\Laravel\Http\Middleware\Etag::class,
\Fruitcake\Cors\HandleCors::class,
]);
$app->routeMiddleware([
......@@ -141,7 +144,10 @@ $app->register(\Jiannei\Enum\Laravel\Providers\LumenServiceProvider::class);
$app->register(\Jiannei\Response\Laravel\Providers\LumenServiceProvider::class);
$app->register(\Jiannei\Logger\Laravel\Providers\ServiceProvider::class);
/*
//跨域问题
$app->register(Fruitcake\Cors\CorsServiceProvider::class);
/*ext
|--------------------------------------------------------------------------
| Load The Application Routes
|--------------------------------------------------------------------------
......
......@@ -15,6 +15,7 @@
"jiannei/laravel-logger": "^1.2",
"jiannei/laravel-response": "^4.0",
"laravel/lumen-framework": "^8.0",
"laravelista/lumen-vendor-publish": "^8.0",
"league/fractal": "^0.19.2",
"prettus/l5-repository": "^2.7",
"spatie/laravel-permission": "^5.1",
......
<?php
return [
/*
|--------------------------------------------------------------------------
| Laravel CORS Options
|--------------------------------------------------------------------------
|
| The allowed_methods and allowed_headers options are case-insensitive.
|
| You don't need to provide both allowed_origins and allowed_origins_patterns.
| If one of the strings passed matches, it is considered a valid origin.
|
| If ['*'] is provided to allowed_methods, allowed_origins or allowed_headers
| all methods / origins / headers are allowed.
|
*/
/*
* You can enable CORS for 1 or multiple paths.
* Example: ['api/*']
*/
'paths' => ['adminapi/*'],
/*
* Matches the request method. `['*']` allows all methods.
*/
'allowed_methods' => ['*'],
/*
* Matches the request origin. `['*']` allows all origins. Wildcards can be used, eg `*.mydomain.com`
*/
'allowed_origins' => ['*'],
/*
* Patterns that can be used with `preg_match` to match the origin.
*/
'allowed_origins_patterns' => [],
/*
* Sets the Access-Control-Allow-Headers response header. `['*']` allows all headers.
*/
'allowed_headers' => ['*'],
/*
* Sets the Access-Control-Expose-Headers response header with these headers.
*/
'exposed_headers' => [],
/*
* Sets the Access-Control-Max-Age response header when > 0.
*/
'max_age' => 0,
/*
* Sets the Access-Control-Allow-Credentials header.
*/
'supports_credentials' => false,
];
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment