Skip to content

Commit

Permalink
Fixed CORS bug
Browse files Browse the repository at this point in the history
  • Loading branch information
rmeissn committed Jul 26, 2018
1 parent 59d039a commit b06f152
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions application/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ const Joi = require('joi'),
os = require('os'),
twitter = require('twitter'),
_ = require('lodash'),
crypto = require('crypto'),
URL = require('url');
crypto = require('crypto');

const twitterclient = new twitter(require('./config.json'));

let CORSHost = process.env.VIRTUAL_HOST.split('.');
CORSHost = CORSHost[CORSHost.length - 2] + '.' + CORSHost[CORSHost.length-1];
console.log('Using ' + CORSHost + ' for CORS headers');

module.exports = function(server) {
server.route({
method: 'GET',
Expand Down Expand Up @@ -51,7 +54,7 @@ module.exports = function(server) {
path: '/token',
handler: getNewRevealMultiplexToken,
config: {
cors: {origin: ['http://localhost*', URL.parse(process.env.VIRTUAL_HOST).hostname]},
cors: {origin: [/*'http://localhost*',*/ '*' + CORSHost]},
tags: ['api'],
description: 'Get a new token pair for the reveal multiplex plugin'
}
Expand Down

0 comments on commit b06f152

Please sign in to comment.