Skip to content

Commit 7748131

Browse files
author
Bryan Kendall
committed
ignoring protocol for cors check
1 parent 4aaa89c commit 7748131

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

lib/middlewares/cors.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
'use strict';
22
var cors = require('cors');
33
var envIs = require('101/env-is');
4+
var url = require('url');
45

56
module.exports = cors({
67
methods: 'GET,PUT,POST,PATCH,DELETE,DEL',
78
origin: function (origin, callback) {
9+
var originParsed = url.parse(origin);
10+
var originMatchesDomain = (originParsed.host === process.env.DOMAIN);
811
var allow = envIs('development', 'test', 'io', 'local', 'staging') ?
912
true :
10-
(origin === 'http://'+process.env.DOMAIN);
13+
(originMatchesDomain);
1114
callback(null, allow);
1215
},
1316
credentials: true

0 commit comments

Comments
 (0)