Skip to content

Commit 563b29b

Browse files
committed
feat(server): enable cors for local SAM instances and deployed Lambda endpoints
1 parent 10f6422 commit 563b29b

File tree

4 files changed

+49
-27
lines changed

4 files changed

+49
-27
lines changed

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
},
1212
"dependencies": {
1313
"aws-serverless-express": "3.1.3",
14+
"cors": "^2.8.5",
1415
"pg": "7.4.1",
15-
"postgraphile": "^4.1.0-rc.2"
16+
"postgraphile": "v4.2",
17+
"postgraphile-core": "^4.2.0"
1618
},
1719
"devDependencies": {
1820
"webpack": "4.17.2",

src/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const awsServerlessExpress = require('aws-serverless-express');
2+
const cors = require('cors');
23
const { postgraphile } = require('postgraphile');
34
const { options } = require('./postgraphileOptions');
45
const combineMiddlewares = require('./combineMiddlewares');
@@ -13,6 +14,7 @@ const app = combineMiddlewares([
1314
*
1415
* This is typically useful for augmenting the request before it goes to PostGraphile.
1516
*/
17+
cors(),
1618
(req, res, next) => {
1719
if (options.absoluteRoutes) {
1820
try {

test/make-template-yml.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ Resources:
2525
Properties:
2626
Path: /
2727
Method: post
28+
OptionsRoute:
29+
Type: Api
30+
Properties:
31+
Path: /
32+
Method: options
2833
Favicon:
2934
Type: Api
3035
Properties:

yarn.lock

Lines changed: 39 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -858,6 +858,14 @@ core-util-is@~1.0.0:
858858
resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7"
859859
integrity sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=
860860

861+
cors@^2.8.5:
862+
version "2.8.5"
863+
resolved "https://registry.yarnpkg.com/cors/-/cors-2.8.5.tgz#eac11da51592dd86b9f06f6e7ac293b3df875d29"
864+
integrity sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==
865+
dependencies:
866+
object-assign "^4"
867+
vary "^1"
868+
861869
create-ecdh@^4.0.0:
862870
version "4.0.3"
863871
resolved "https://registry.yarnpkg.com/create-ecdh/-/create-ecdh-4.0.3.tgz#c9111b6f33045c4697f144787f9254cdc77c45ff"
@@ -1381,30 +1389,30 @@ graceful-fs@^4.1.11, graceful-fs@^4.1.2:
13811389
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658"
13821390
integrity sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=
13831391

1384-
graphile-build-pg@4.1.0-rc.2:
1385-
version "4.1.0-rc.2"
1386-
resolved "https://registry.yarnpkg.com/graphile-build-pg/-/graphile-build-pg-4.1.0-rc.2.tgz#b059e8f22bcb96bd04820c217cb6dc463fa1fc27"
1387-
integrity sha512-n3d1rFncSVqNZSzWOhog21/E67M2o8T0ppVQBNgvCOec+byKy++6nBKUoxzhVyxNyzAYwY7Y9oySXgiKnajyoA==
1392+
graphile-build-pg@4.2.0:
1393+
version "4.2.0"
1394+
resolved "https://registry.yarnpkg.com/graphile-build-pg/-/graphile-build-pg-4.2.0.tgz#4c8b279b94bcafb0bfc21b32f542660bf32f53b1"
1395+
integrity sha512-UApYkNb0aIkT/6MjInXniH3eTH4H2I9sR0biaulwBAXLukqpB/ttxWrzWbbGZF4dWZ0+uRjZNNyrK5OGdsHHtg==
13881396
dependencies:
13891397
chalk "^2.1.0"
13901398
debug ">=2 <3"
1391-
graphile-build "4.1.0-rc.2"
1399+
graphile-build "4.1.0"
13921400
graphql-iso-date "^3.6.0"
13931401
jsonwebtoken "^8.1.1"
13941402
lodash ">=4 <5"
13951403
lru-cache ">=4 <5"
13961404
pg-sql2 "2.2.1"
13971405
postgres-interval "^1.1.1"
13981406

1399-
1400-
version "4.1.0-rc.2"
1401-
resolved "https://registry.yarnpkg.com/graphile-build/-/graphile-build-4.1.0-rc.2.tgz#71749419a92d2126eff1bddb72f1b6169494fed8"
1402-
integrity sha512-pNRvAWerwDmRGJP7alyevUum/K9fBkJcH3oQb9gEo0R0TVFEId5T4Ccfq5wc0vogazEvJ7oSyNN4PIryPDHbbw==
1407+
1408+
version "4.1.0"
1409+
resolved "https://registry.yarnpkg.com/graphile-build/-/graphile-build-4.1.0.tgz#d1ee6bee8c53ec1b82db3dcd9a343151bdaac8f2"
1410+
integrity sha512-N1IEmDDgTPIf4jpLVuyhdiuQBpKNu8lMpnVTTmfuYf5GZvGz6hJzTvSZREnIoF3lPQ+JS4zMfb7KuVNOYdYu8Q==
14031411
dependencies:
14041412
"@types/graphql" "^14.0.3"
14051413
chalk "^2.1.0"
14061414
debug ">=2 <3"
1407-
graphql-parse-resolve-info "4.1.0-rc.2"
1415+
graphql-parse-resolve-info "4.1.0"
14081416
lodash ">=4 <5"
14091417
lru-cache ">=4 <5"
14101418
pluralize "^7.0.0"
@@ -1415,10 +1423,10 @@ graphql-iso-date@^3.6.0:
14151423
resolved "https://registry.yarnpkg.com/graphql-iso-date/-/graphql-iso-date-3.6.1.tgz#bd2d0dc886e0f954cbbbc496bbf1d480b57ffa96"
14161424
integrity sha512-AwFGIuYMJQXOEAgRlJlFL4H1ncFM8n8XmoVDTNypNOZyQ8LFDG2ppMFlsS862BSTCDcSUfHp8PD3/uJhv7t59Q==
14171425

1418-
1419-
version "4.1.0-rc.2"
1420-
resolved "https://registry.yarnpkg.com/graphql-parse-resolve-info/-/graphql-parse-resolve-info-4.1.0-rc.2.tgz#e93ef370f9c7b5caa1712ea3dfa3090944887383"
1421-
integrity sha512-t7HmxMfCddgaBONr/Ss8jtaZd+4nkX5LkEkVfTZR59XeR03XFUkXBvz/4gMm/luN1z5Rxv6FRsIu1JKOK6Fu4g==
1426+
1427+
version "4.1.0"
1428+
resolved "https://registry.yarnpkg.com/graphql-parse-resolve-info/-/graphql-parse-resolve-info-4.1.0.tgz#fa52bc9d8aeec210e3ad92cca30d3c36a5e814c3"
1429+
integrity sha512-qDRgykBm1rbyGAlduPuGtKXHlZtUcNgM8Rg6C/gDVcLww9vNV6h0nmCulpYYPWzATnAVGV8ISnLUDFCU9Y+qcA==
14221430
dependencies:
14231431
"@types/graphql" "^14.0.3"
14241432
debug ">=2 <3"
@@ -2300,7 +2308,7 @@ number-is-nan@^1.0.0:
23002308
resolved "https://registry.yarnpkg.com/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d"
23012309
integrity sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=
23022310

2303-
object-assign@^4.1.0:
2311+
object-assign@^4, object-assign@^4.1.0:
23042312
version "4.1.1"
23052313
resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863"
23062314
integrity sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=
@@ -2584,19 +2592,19 @@ posix-character-classes@^0.1.0:
25842592
resolved "https://registry.yarnpkg.com/posix-character-classes/-/posix-character-classes-0.1.1.tgz#01eac0fe3b5af71a2a6c02feabb8c1fef7e00eab"
25852593
integrity sha1-AerA/jta9xoqbAL+q7jB/vfgDqs=
25862594

2587-
postgraphile-core@4.1.0-rc.2:
2588-
version "4.1.0-rc.2"
2589-
resolved "https://registry.yarnpkg.com/postgraphile-core/-/postgraphile-core-4.1.0-rc.2.tgz#780cb09b6f4404308343616396d0221186412031"
2590-
integrity sha512-XMMBBsHTUp4ge+b2FCoknICFwQyRZpgJJOyKrFR0xPIulNY3V0CBq90yzXvPFXfmU68GjuR1eAMR9//0I6FSWw==
2595+
postgraphile-core@4.2.0, postgraphile-core@^4.2.0:
2596+
version "4.2.0"
2597+
resolved "https://registry.yarnpkg.com/postgraphile-core/-/postgraphile-core-4.2.0.tgz#ee5d42f04629ce1225665fedb78f491b1f8491f0"
2598+
integrity sha512-9SJKV+/0jINUUPQPN3TtoSEG4tI47DOZEY9Qg4sq6Yxnf5/Yr9OFImLUj8c6wxfvq5/+7Ajqny1OGnS1fnwg1Q==
25912599
dependencies:
25922600
"@types/graphql" "^14.0.3"
2593-
graphile-build "4.1.0-rc.2"
2594-
graphile-build-pg "4.1.0-rc.2"
2601+
graphile-build "4.1.0"
2602+
graphile-build-pg "4.2.0"
25952603

2596-
postgraphile@^4.1.0-rc.2:
2597-
version "4.1.0-rc.2"
2598-
resolved "https://registry.yarnpkg.com/postgraphile/-/postgraphile-4.1.0-rc.2.tgz#07fef429a9b7380314a9ed0143b16cf90773bc84"
2599-
integrity sha512-/76vH7+kcjUUMJskJVAcK84VhfbVQF9PwZZYGLZClbYdCU4Sfk0TJNO+KDai/EgBiRCq+7ptWCMAECDe2koOaw==
2604+
postgraphile@v4.2:
2605+
version "4.2.0"
2606+
resolved "https://registry.yarnpkg.com/postgraphile/-/postgraphile-4.2.0.tgz#1a3401ff827b5d2cfb3fe49a58fae5d93145ce09"
2607+
integrity sha512-S6aHo0R951wWZJLKf/jPKkRw9HhtygPL57+yZGEuWTgcHpayqG7lC3A5Zplkatlwg8ASD4w1X+7QnY8tL4YDxg==
26002608
dependencies:
26012609
"@types/graphql" "^14.0.3"
26022610
"@types/jsonwebtoken" "<7.2.1"
@@ -2615,7 +2623,7 @@ postgraphile@^4.1.0-rc.2:
26152623
pg ">=6.1.0 <8"
26162624
pg-connection-string "^0.1.3"
26172625
pg-sql2 "^2.2.1"
2618-
postgraphile-core "4.1.0-rc.2"
2626+
postgraphile-core "4.2.0"
26192627
tslib "^1.5.0"
26202628

26212629
postgres-array@~1.0.0:
@@ -3403,6 +3411,11 @@ v8-compile-cache@^2.0.0:
34033411
resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.0.2.tgz#a428b28bb26790734c4fc8bc9fa106fccebf6a6c"
34043412
integrity sha512-1wFuMUIM16MDJRCrpbpuEPTUGmM5QMUg0cr3KFwra2XgOgFcPGDQHDh3CszSCD2Zewc/dh/pamNEW8CbfDebUw==
34053413

3414+
vary@^1:
3415+
version "1.1.2"
3416+
resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc"
3417+
integrity sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=
3418+
34063419
34073420
version "0.0.4"
34083421
resolved "https://registry.yarnpkg.com/vm-browserify/-/vm-browserify-0.0.4.tgz#5d7ea45bbef9e4a6ff65f95438e0a87c357d5a73"

0 commit comments

Comments
 (0)