Skip to content

Commit

Permalink
Bugfix
Browse files Browse the repository at this point in the history
Now always setting a application/javascript header to prevent issues when using nginx as reverse proxy.
  • Loading branch information
explodingcamera committed May 26, 2016
1 parent 2ebceaf commit a8d3405
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions webserver/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,12 @@ var socketServer = null;

if (config.certificate && config.certificate.key && config.certificate.cert){
server = https.createServer(config.certificate, app);
if(config.webServer.redirectHTTP && config.webServer.redirectPort != ''){
if(config.webServer.redirectHTTP && config.webServer.redirectPort != '')
server2 = http.createServer(app);
}
}else{
server = http.createServer(app);
}

//var server = http.createServer(app);

else {
server = http.createServer(app);
}

app.use(function(req, res, next) {
if(!req.secure && config.webServer.redirectHTTP) {
Expand All @@ -32,9 +29,10 @@ app.use(function(req, res, next) {
app.use(express.static(path.resolve(__dirname, 'public')));
app.use('/pads', express.static(path.resolve(__dirname, 'public')));
app.get('/config', function(req, res) {
res.send(fs.readFileSync(__dirname + '/public/lib/js/webconfig.js'));
res.setHeader("Content-Type", "application/javascript");
res.send(fs.readFileSync(__dirname + '/public/lib/js/webconfig.js'));
});
app.get('/api/room', function(req,res){
app.get('/api/room', function(req, res) {
var roomInfo = {
"slug": config.room.slug,
"name": config.room.name,
Expand Down Expand Up @@ -62,4 +60,4 @@ var setSocketServer = function(ss){
};


module.exports = {app: app, server: server, server2: server2, setSocketServer: setSocketServer};
module.exports = {app: app, server: server, server2: server2, setSocketServer: setSocketServer};

0 comments on commit a8d3405

Please sign in to comment.