Skip to content

Commit 3d991f5

Browse files
authored
feat(node-server): Pass options to the CORS middleware via corsOptions
1 parent ad603d3 commit 3d991f5

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

docs/node-server/overview.md

+16
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,22 @@ new Server({
8383
});
8484
```
8585

86+
### corsOptions
87+
88+
_Type_: `Object | Function`
89+
_Default_: `undefined`
90+
91+
Options passed to the ([CORS](https://github.com/expressjs/cors)) middleware.
92+
93+
```js
94+
new Server({
95+
corsOptions: {
96+
origin: 'http://localhost:4000',
97+
credentials: true
98+
}
99+
});
100+
```
101+
86102
## API Configuration
87103

88104
### recordingsDir

packages/@pollyjs/node-server/src/server.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default class Server {
1212
constructor(config = {}) {
1313
this.config = { ...DefaultConfig, ...config };
1414
this.app = express();
15-
this.app.use(cors());
15+
this.app.use(cors(this.config.corsOptions));
1616

1717
if (!this.config.quiet) {
1818
this.app.use(morgan('dev'));

0 commit comments

Comments
 (0)