Skip to content

Commit

Permalink
feat(node-server): Add cors support to express server to pass-through…
Browse files Browse the repository at this point in the history
… all requests

* fix: Do not disable node server listening banner in quiet mode

* feat: Adds cors support to express server to pass through all requests
  • Loading branch information
jasonmit authored and offirgolan committed Jun 29, 2018
1 parent 1be57a7 commit 223ce4e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/@pollyjs/node-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
},
"dependencies": {
"body-parser": "^1.18.3",
"cors": "^2.8.4",
"express": "^4.16.3",
"fs-extra": "^5.0.0",
"http-graceful-shutdown": "^2.1.1",
Expand Down
2 changes: 2 additions & 0 deletions packages/@pollyjs/node-server/src/server.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* global process */

import cors from 'cors';
import morgan from 'morgan';
import express from 'express';
import gracefulShutdown from 'http-graceful-shutdown';
Expand All @@ -10,6 +11,7 @@ export default class Server {
constructor(config = {}) {
this.config = { ...DefaultConfig, ...config };
this.app = express();
this.app.use(cors());

if (!this.config.quiet) {
this.app.use(morgan('dev'));
Expand Down
11 changes: 9 additions & 2 deletions packages/@pollyjs/node-server/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,13 @@ core-util-is@~1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7"

cors@^2.8.4:
version "2.8.4"
resolved "https://registry.yarnpkg.com/cors/-/cors-2.8.4.tgz#2bd381f2eb201020105cd50ea59da63090694686"
dependencies:
object-assign "^4"
vary "^1"

cross-spawn@^5.1.0:
version "5.1.0"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-5.1.0.tgz#e8bd0efee58fcff6f8f94510a0a554bbfa235449"
Expand Down Expand Up @@ -948,7 +955,7 @@ npm-run-all@^4.1.2:
shell-quote "^1.6.1"
string.prototype.padend "^3.0.0"

object-assign@^4.0.1:
object-assign@^4, object-assign@^4.0.1:
version "4.1.1"
resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863"

Expand Down Expand Up @@ -1419,7 +1426,7 @@ validate-npm-package-license@^3.0.1:
spdx-correct "^3.0.0"
spdx-expression-parse "^3.0.0"

vary@~1.1.2:
vary@^1, vary@~1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc"

Expand Down

0 comments on commit 223ce4e

Please sign in to comment.