# HG changeset patch # User ymh # Date 1453481005 -3600 # Node ID 16e1473a6a994979ee6d9f603d14e8636028fda4 # Parent 30de363937ce8b8adb0345a1c4555dacdd307736 add cors support for api diff -r 30de363937ce -r 16e1473a6a99 server/bo_client/app/adapters/application.js --- a/server/bo_client/app/adapters/application.js Fri Jan 22 17:09:33 2016 +0100 +++ b/server/bo_client/app/adapters/application.js Fri Jan 22 17:43:25 2016 +0100 @@ -3,4 +3,6 @@ export default RESTAdapter.extend({ namespace: ENV.baseURL.replace(/\/$/,"")+'/api/v1', + //TODO: pass this as configuration + //host: 'http://localhost:8000' }); diff -r 30de363937ce -r 16e1473a6a99 server/src/app/Http/routes.php --- a/server/src/app/Http/routes.php Fri Jan 22 17:09:33 2016 +0100 +++ b/server/src/app/Http/routes.php Fri Jan 22 17:43:25 2016 +0100 @@ -35,7 +35,7 @@ | */ -Route::group(['prefix' => 'api/v1'] , function() { +Route::group(['prefix' => 'api/v1', 'middleware' => 'cors'] , function() { Route::resource('documents', 'Api\DocumentController', ['only' => ['index', 'show', 'update']]); Route::resource('viaf', 'Api\ViafController', diff -r 30de363937ce -r 16e1473a6a99 server/src/composer.json --- a/server/src/composer.json Fri Jan 22 17:09:33 2016 +0100 +++ b/server/src/composer.json Fri Jan 22 17:43:25 2016 +0100 @@ -12,7 +12,9 @@ "caseyamcl/phpoaipmh": "~2.4", "guzzlehttp/guzzle": "~6.1", "laravelcollective/html": "5.2.*", - "shift31/laravel-elasticsearch": "~1.0" + "shift31/laravel-elasticsearch": "~1.0", + "asm89/stack-cors": "dev-master as 0.2.2", + "barryvdh/laravel-cors": "^0.7.3" }, "require-dev": { "fzaninotto/faker": "~1.4", diff -r 30de363937ce -r 16e1473a6a99 server/src/composer.lock --- a/server/src/composer.lock Fri Jan 22 17:09:33 2016 +0100 +++ b/server/src/composer.lock Fri Jan 22 17:43:25 2016 +0100 @@ -4,10 +4,102 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "4cc41d3186842209dba3082cd3156e0e", - "content-hash": "442658097805a38929e27868d8d28bfe", + "hash": "ecc6d0272a0d14ba45ce33679ce18fc8", + "content-hash": "87afb5e719b066d835d2e52b7d178abe", "packages": [ { + "name": "asm89/stack-cors", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/asm89/stack-cors.git", + "reference": "f76d3ff80f287dcdf18cec0855efd6787cc1c7a5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/asm89/stack-cors/zipball/f76d3ff80f287dcdf18cec0855efd6787cc1c7a5", + "reference": "f76d3ff80f287dcdf18cec0855efd6787cc1c7a5", + "shasum": "" + }, + "require": { + "php": ">=5.3.2", + "symfony/http-foundation": "~2.1|~3.0", + "symfony/http-kernel": "~2.1|~3.0" + }, + "type": "library", + "autoload": { + "psr-0": { + "Asm89\\Stack": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Alexander", + "email": "iam.asm89@gmail.com" + } + ], + "description": "Cross-origin resource sharing library and stack middleware", + "homepage": "https://github.com/asm89/stack-cors", + "keywords": [ + "cors", + "stack" + ], + "time": "2015-12-23 16:04:18" + }, + { + "name": "barryvdh/laravel-cors", + "version": "v0.7.3", + "source": { + "type": "git", + "url": "https://github.com/barryvdh/laravel-cors.git", + "reference": "e4c4545879f5f00b8595a13fcf8e648b9bfdb40a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/barryvdh/laravel-cors/zipball/e4c4545879f5f00b8595a13fcf8e648b9bfdb40a", + "reference": "e4c4545879f5f00b8595a13fcf8e648b9bfdb40a", + "shasum": "" + }, + "require": { + "asm89/stack-cors": "0.2.x", + "illuminate/support": "~5.0.14|5.1.x|5.2.x", + "php": ">=5.4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.7-dev" + } + }, + "autoload": { + "psr-4": { + "Barryvdh\\Cors\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Barry vd. Heuvel", + "email": "barryvdh@gmail.com" + } + ], + "description": "Adds CORS (Cross-Origin Resource Sharing) headers support in your Laravel application", + "keywords": [ + "api", + "cors", + "crossdomain", + "laravel" + ], + "time": "2015-12-20 20:32:17" + }, + { "name": "caseyamcl/phpoaipmh", "version": "v2.4", "source": { @@ -880,16 +972,16 @@ }, { "name": "laravelcollective/html", - "version": "v5.2", + "version": "v5.2.3", "source": { "type": "git", "url": "https://github.com/LaravelCollective/html.git", - "reference": "5a8f1380a0d5ef21cdef37e775d86566307f8358" + "reference": "7ec0ca55cab54cc6d331007d86ec068b61f46aad" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/LaravelCollective/html/zipball/5a8f1380a0d5ef21cdef37e775d86566307f8358", - "reference": "5a8f1380a0d5ef21cdef37e775d86566307f8358", + "url": "https://api.github.com/repos/LaravelCollective/html/zipball/7ec0ca55cab54cc6d331007d86ec068b61f46aad", + "reference": "7ec0ca55cab54cc6d331007d86ec068b61f46aad", "shasum": "" }, "require": { @@ -930,7 +1022,7 @@ ], "description": "HTML and Form Builders for the Laravel Framework", "homepage": "http://laravelcollective.com", - "time": "2015-12-23 07:46:46" + "time": "2016-01-20 18:28:21" }, { "name": "league/flysystem", @@ -1065,22 +1157,22 @@ }, { "name": "ml/json-ld", - "version": "1.0.4", + "version": "1.0.5", "target-dir": "ML/JsonLD", "source": { "type": "git", "url": "https://github.com/lanthaler/JsonLD.git", - "reference": "cfd07313cc1ac2fa3b80887ceb39feee1b0cd626" + "reference": "2f7f00a9daed844289135cc1cc99a75fc72a5438" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/lanthaler/JsonLD/zipball/cfd07313cc1ac2fa3b80887ceb39feee1b0cd626", - "reference": "cfd07313cc1ac2fa3b80887ceb39feee1b0cd626", + "url": "https://api.github.com/repos/lanthaler/JsonLD/zipball/2f7f00a9daed844289135cc1cc99a75fc72a5438", + "reference": "2f7f00a9daed844289135cc1cc99a75fc72a5438", "shasum": "" }, "require": { "ext-json": "*", - "ml/iri": ">=1.1.1", + "ml/iri": "^1.1.1", "php": ">=5.3.0" }, "require-dev": { @@ -1110,7 +1202,7 @@ "JSON-LD", "jsonld" ], - "time": "2015-12-22 12:43:50" + "time": "2016-01-17 17:39:22" }, { "name": "monolog/monolog", @@ -2561,16 +2653,16 @@ }, { "name": "fabpot/php-cs-fixer", - "version": "v1.11", + "version": "v1.11.1", "source": { "type": "git", "url": "https://github.com/FriendsOfPHP/PHP-CS-Fixer.git", - "reference": "bd3ec2c2b774e0e127ac2c737ec646d9cf2f9eef" + "reference": "2c9f8298181f059c5077abda78019b9a0c9a7cc0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/bd3ec2c2b774e0e127ac2c737ec646d9cf2f9eef", - "reference": "bd3ec2c2b774e0e127ac2c737ec646d9cf2f9eef", + "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/2c9f8298181f059c5077abda78019b9a0c9a7cc0", + "reference": "2c9f8298181f059c5077abda78019b9a0c9a7cc0", "shasum": "" }, "require": { @@ -2611,7 +2703,59 @@ } ], "description": "A tool to automatically fix PHP code style", - "time": "2015-12-01 22:34:33" + "time": "2016-01-20 19:00:28" + }, + { + "name": "fzaninotto/faker", + "version": "v1.5.0", + "source": { + "type": "git", + "url": "https://github.com/fzaninotto/Faker.git", + "reference": "d0190b156bcca848d401fb80f31f504f37141c8d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/fzaninotto/Faker/zipball/d0190b156bcca848d401fb80f31f504f37141c8d", + "reference": "d0190b156bcca848d401fb80f31f504f37141c8d", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.0", + "squizlabs/php_codesniffer": "~1.5" + }, + "suggest": { + "ext-intl": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.5.x-dev" + } + }, + "autoload": { + "psr-4": { + "Faker\\": "src/Faker/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "François Zaninotto" + } + ], + "description": "Faker is a PHP library that generates fake data for you.", + "keywords": [ + "data", + "faker", + "fixtures" + ], + "time": "2015-05-29 06:29:14" }, { "name": "hamcrest/hamcrest-php", @@ -4026,14 +4170,24 @@ "time": "2015-12-26 13:39:53" } ], - "aliases": [], + "aliases": [ + { + "alias": "0.2.2", + "alias_normalized": "0.2.2.0", + "version": "9999999-dev", + "package": "asm89/stack-cors" + } + ], "minimum-stability": "stable", "stability-flags": { "easyrdf/easyrdf": 20, + "asm89/stack-cors": 20, "mockery/mockery": 20 }, "prefer-stable": false, "prefer-lowest": false, - "platform": [], + "platform": { + "php": ">=5.5.9" + }, "platform-dev": [] } diff -r 30de363937ce -r 16e1473a6a99 server/src/config/app.php --- a/server/src/config/app.php Fri Jan 22 17:09:33 2016 +0100 +++ b/server/src/config/app.php Fri Jan 22 17:43:25 2016 +0100 @@ -141,6 +141,7 @@ */ 'Collective\Html\HtmlServiceProvider', 'Shift31\LaravelElasticsearch\ElasticsearchServiceProvider', + 'Barryvdh\Cors\ServiceProvider', /* * Application Service Providers... diff -r 30de363937ce -r 16e1473a6a99 server/src/config/cors.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/server/src/config/cors.php Fri Jan 22 17:43:25 2016 +0100 @@ -0,0 +1,21 @@ + false, + 'allowedOrigins' => ['*'], + 'allowedHeaders' => ['*'], + 'allowedMethods' => ['GET',], + 'exposedHeaders' => [], + 'maxAge' => 0, + 'hosts' => [], +];