Skip to content

Commit 8768f77

Browse files
Merge pull request #5 from MrYamous/fix/cors
Add CORS
2 parents 3daa8c4 + d7603be commit 8768f77

File tree

7 files changed

+88
-3
lines changed

7 files changed

+88
-3
lines changed

back/.env

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,8 @@ APP_SECRET=23e6d6e8cc8208134d03ed1594123320
3030
# For a PostgreSQL database, use: "postgresql://db_user:[email protected]:5432/db_name?serverVersion=11&charset=utf8"
3131
# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml
3232
DATABASE_URL=mysql://root:root@localhost/jsworker?serverVersion=5.7
33-
###< doctrine/doctrine-bundle ###
33+
###< doctrine/doctrine-bundle ###
34+
35+
###> nelmio/cors-bundle ###
36+
CORS_ALLOW_ORIGIN=^https?://localhost(:[0-9]+)?$
37+
###< nelmio/cors-bundle ###

back/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"ext-ctype": "*",
77
"ext-iconv": "*",
88
"jms/serializer": "^3.3",
9+
"nelmio/cors-bundle": "^2.0",
910
"sensio/framework-extra-bundle": "^5.5",
1011
"symfony/apache-pack": "^1.0",
1112
"symfony/console": "5.0.*",

back/composer.lock

Lines changed: 58 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

back/config/bundles.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@
1111
Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true],
1212
Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true],
1313
Symfony\Bundle\DebugBundle\DebugBundle::class => ['dev' => true, 'test' => true],
14+
Nelmio\CorsBundle\NelmioCorsBundle::class => ['all' => true],
1415
];
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
nelmio_cors:
2+
defaults:
3+
origin_regex: true
4+
allow_origin: ['%env(CORS_ALLOW_ORIGIN)%']
5+
allow_methods: ['GET', 'OPTIONS', 'POST', 'PUT', 'PATCH', 'DELETE']
6+
allow_headers: ['Content-Type', 'Authorization']
7+
expose_headers: ['Link']
8+
max_age: 3600
9+
paths:
10+
'^/': null

back/src/DataFixtures/AppFixtures.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public function load(ObjectManager $manager)
1313
{
1414
$faker = Faker\Factory::create();
1515

16-
for ($i = 0; $i < 50; $i++) {
16+
for ($i = 0; $i < 55; $i++) {
1717

1818
$user = new User();
1919
$user->setAge($faker->numberBetween(3, 90));

back/symfony.lock

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,18 @@
156156
"monolog/monolog": {
157157
"version": "2.0.1"
158158
},
159+
"nelmio/cors-bundle": {
160+
"version": "1.5",
161+
"recipe": {
162+
"repo": "github.com/symfony/recipes",
163+
"branch": "master",
164+
"version": "1.5",
165+
"ref": "6388de23860284db9acce0a7a5d9d13153bcb571"
166+
},
167+
"files": [
168+
"config/packages/nelmio_cors.yaml"
169+
]
170+
},
159171
"nikic/php-parser": {
160172
"version": "v4.3.0"
161173
},

0 commit comments

Comments
 (0)