diff --git a/.env b/.env index a68e687..9f0a5a2 100644 --- a/.env +++ b/.env @@ -18,3 +18,7 @@ APP_ENV=dev APP_SECRET=7f0dfc149d55b4ca2cf7bcc72c5ff7e1 ###< symfony/framework-bundle ### + +###> nelmio/cors-bundle ### +CORS_ALLOW_ORIGIN='^.*$' +###< nelmio/cors-bundle ### diff --git a/composer.json b/composer.json index 0d58fe2..c3cd188 100644 --- a/composer.json +++ b/composer.json @@ -10,6 +10,7 @@ "doctrine/doctrine-bundle": "^2.8", "doctrine/doctrine-migrations-bundle": "^3.2", "doctrine/orm": "^2.14", + "nelmio/cors-bundle": "^2.3", "symfony/console": "6.2.*", "symfony/dotenv": "6.2.*", "symfony/flex": "^2", diff --git a/composer.lock b/composer.lock index 260f186..d889b53 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "be908ba5be5e9374ed2c204323f7eb68", + "content-hash": "8c347e5731168f0bd4347dc00befcace", "packages": [ { "name": "doctrine/cache", @@ -1458,6 +1458,68 @@ ], "time": "2022-12-08T02:08:23+00:00" }, + { + "name": "nelmio/cors-bundle", + "version": "2.3.1", + "source": { + "type": "git", + "url": "https://github.com/nelmio/NelmioCorsBundle.git", + "reference": "185d2c0ae50a3f0b628790170164d5f1c5b7c281" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nelmio/NelmioCorsBundle/zipball/185d2c0ae50a3f0b628790170164d5f1c5b7c281", + "reference": "185d2c0ae50a3f0b628790170164d5f1c5b7c281", + "shasum": "" + }, + "require": { + "psr/log": "^1.0 || ^2.0 || ^3.0", + "symfony/framework-bundle": "^4.4 || ^5.4 || ^6.0" + }, + "require-dev": { + "mockery/mockery": "^1.2", + "symfony/phpunit-bridge": "^4.4 || ^5.4 || ^6.0" + }, + "type": "symfony-bundle", + "extra": { + "branch-alias": { + "dev-master": "2.x-dev" + } + }, + "autoload": { + "psr-4": { + "Nelmio\\CorsBundle\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nelmio", + "homepage": "http://nelm.io" + }, + { + "name": "Symfony Community", + "homepage": "https://github.com/nelmio/NelmioCorsBundle/contributors" + } + ], + "description": "Adds CORS (Cross-Origin Resource Sharing) headers support in your Symfony application", + "keywords": [ + "api", + "cors", + "crossdomain" + ], + "support": { + "issues": "https://github.com/nelmio/NelmioCorsBundle/issues", + "source": "https://github.com/nelmio/NelmioCorsBundle/tree/2.3.1" + }, + "time": "2023-02-16T08:49:29+00:00" + }, { "name": "psr/cache", "version": "3.0.0", diff --git a/config/bundles.php b/config/bundles.php index de8898b..e4e91d7 100644 --- a/config/bundles.php +++ b/config/bundles.php @@ -5,4 +5,5 @@ return [ Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true], Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true], Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true], + Nelmio\CorsBundle\NelmioCorsBundle::class => ['all' => true], ]; diff --git a/config/packages/nelmio_cors.yaml b/config/packages/nelmio_cors.yaml new file mode 100644 index 0000000..c766508 --- /dev/null +++ b/config/packages/nelmio_cors.yaml @@ -0,0 +1,10 @@ +nelmio_cors: + defaults: + origin_regex: true + allow_origin: ['%env(CORS_ALLOW_ORIGIN)%'] + allow_methods: ['GET', 'OPTIONS', 'POST', 'PUT', 'PATCH', 'DELETE'] + allow_headers: ['Content-Type', 'Authorization'] + expose_headers: ['Link'] + max_age: 3600 + paths: + '^/': null diff --git a/symfony.lock b/symfony.lock index 26b15a1..4bc0254 100644 --- a/symfony.lock +++ b/symfony.lock @@ -26,6 +26,18 @@ "migrations/.gitignore" ] }, + "nelmio/cors-bundle": { + "version": "2.3", + "recipe": { + "repo": "github.com/symfony/recipes", + "branch": "main", + "version": "1.5", + "ref": "6bea22e6c564fba3a1391615cada1437d0bde39c" + }, + "files": [ + "config/packages/nelmio_cors.yaml" + ] + }, "symfony/console": { "version": "6.2", "recipe": {