Skip to content

Commit 157bdd8

Browse files
authored
refactor: cors options parameter simplified
1 parent c6a557c commit 157bdd8

1 file changed

Lines changed: 7 additions & 15 deletions

File tree

src/index.js

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -70,23 +70,15 @@ if (program.verbose) {
7070
});
7171
}
7272

73-
var corsOptionsDelegate = function (req, callback) {
74-
var corsOptions = {
75-
origin: true,
76-
credentials: true,
77-
methods: "GET,HEAD,PUT,PATCH,POST,DELETE",
78-
preflightContinue: false,
79-
optionsSuccessStatus: 204
80-
};
81-
callback(null, corsOptions);
73+
var corsOptions = {
74+
origin: true,
75+
credentials: true,
76+
methods: "GET,HEAD,PUT,PATCH,POST,DELETE",
77+
preflightContinue: false,
78+
optionsSuccessStatus: 204
8279
};
8380

84-
/*By default "cors()" set the Access-Control-Allow-Origin to "*" which Chrome will reject when the request was made with "credentials" flag enabled. It throws error something like:
85-
A wildcard '*' cannot be used in the 'Access-Control-Allow-Origin' header when the credentials flag is true. */
86-
87-
app.use(cors(corsOptionsDelegate));
88-
89-
//app.use(cors());
81+
app.use(cors(corsOptions));
9082

9183
for (var path in config.map) {
9284
(function (basePath) {

0 commit comments

Comments
 (0)