Skip to content

Commit c6a557c

Browse files
authored
Update index.js
1 parent 1416ca3 commit c6a557c

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

src/index.js

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

73-
app.use(cors());
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);
82+
};
83+
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());
7490

7591
for (var path in config.map) {
7692
(function (basePath) {

0 commit comments

Comments
 (0)