Skip to content

Commit

Permalink
Add cors for swagger (#590)
Browse files Browse the repository at this point in the history
  • Loading branch information
xepozz committed Jun 21, 2023
1 parent a5d1bd2 commit 45e8379
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion blog-api/config/common/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Yiisoft\Router\UrlGeneratorInterface;
use Yiisoft\Swagger\Middleware\SwaggerJson;
use Yiisoft\Swagger\Middleware\SwaggerUi;
use Yiisoft\Yii\Middleware\CorsAllowAll;

return [
Route::get('/')
Expand Down Expand Up @@ -61,6 +62,7 @@
}),
Route::get('/openapi.json')
->middleware(FormatDataResponseAsJson::class)
->action(SwaggerJson::class),
->middleware(CorsAllowAll::class)
->action([SwaggerJson::class, 'handle']),
),
];
4 changes: 3 additions & 1 deletion blog/config/common/routes/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
use Yiisoft\Router\UrlGeneratorInterface;
use Yiisoft\Swagger\Middleware\SwaggerJson;
use Yiisoft\Swagger\Middleware\SwaggerUi;
use Yiisoft\Yii\Middleware\CorsAllowAll;
use Yiisoft\Yii\Middleware\HttpCache;
use Yiisoft\Yii\RateLimiter\Counter;
use Yiisoft\Yii\RateLimiter\LimitRequestsMiddleware;
Expand Down Expand Up @@ -174,6 +175,7 @@
->name('swagger/index'),
Route::get('/openapi.json')
->middleware(FormatDataResponseAsJson::class)
->action(SwaggerJson::class),
->middleware(CorsAllowAll::class)
->action([SwaggerJson::class, 'handle']),
),
];

0 comments on commit 45e8379

Please sign in to comment.