2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Laravel 5.4にbarryvdh/laravel-corsを導入する

Posted at

導入手順

barryvdh/laravel-corsパッケージを取得

  • composer requireでパッケージを取得する。

    console
     cd (/your/laravel/project/path)
     composer require barryvdh/laravel-cors
    
  • config/app.phpを編集する

    config/app.php
     <?php
     
     return [
     	// ...
     	'providers'       => [
     		// ...
     		//barryvdh/laravel-cors
         	Barryvdh\Cors\ServiceProvider::class,
     	],
     	// ...
     
     ];
     
    
  • middleware追加

    app/Http/Kernel.php
     // ...
     protected $middlewareGroups = [
     	// ...
         'api' => [
             // ...
             \Barryvdh\Cors\HandleCors::class,
         ],
     ];
    
  • 設定ファイル生成

    console
     cd (/your/laravel/project/path)
     php artisan vendor:publish --provider="Barryvdh\Cors\ServiceProvider"
    
2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?