Skip to content

Commit dd12c9f

Browse files
committed
Merge branch 'master' of github.com:FREEZX/node-jsonrpc2 into FREEZX-master
2 parents f5a437a + 0e70e16 commit dd12c9f

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/server.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,18 @@ module.exports = function (classes) {
116116
*/
117117
handleHttp: function (req, res) {
118118
var buffer = '', self = this;
119+
var headers;
120+
121+
if (req.method === 'OPTIONS') {
122+
headers = {
123+
'Content-Length': 0,
124+
'Access-Control-Allow-Headers': 'Accept, Authorization, Content-Type'
125+
};
126+
headers = extend(self.opts.headers, headers);
127+
res.writeHead(200, headers);
128+
res.end();
129+
return;
130+
}
119131

120132
if (!self._checkAuth(req, res)) {
121133
return;
@@ -148,7 +160,8 @@ module.exports = function (classes) {
148160
}
149161

150162
var reply = function reply(json) {
151-
var encoded, headers = {
163+
var encoded;
164+
headers = {
152165
'Content-Type': 'application/json'
153166
};
154167

0 commit comments

Comments
 (0)