ebac854da8
* The MongoDB/Mongoose data storage is removed in favor of Sequelize. This abstracts over SQLite or RDBMs like PostgreSQL and MSSQL. The default is SQLite, which significantly simplifies deployments in end-user environments. * As Spacedeck now has no more mandatory server dependencies, we can wrap it in Electron and ship it as a desktop application. * Removes docker-compose.yml * First version of import UI
49 lines
1.5 KiB
JavaScript
49 lines
1.5 KiB
JavaScript
'use strict';
|
|
|
|
require('../models/db');
|
|
const config = require('config');
|
|
const url = require('url');
|
|
|
|
function respond(origin, req, res, next) {
|
|
res.header('Access-Control-Allow-Origin', origin);
|
|
res.header('Access-Control-Allow-Credentials', true);
|
|
res.header('Access-Control-Max-Age', 60 * 60 * 24);
|
|
res.header('Access-Control-Expose-Headers', 'Accepts, Content-Type, X-Spacedeck-Space-Role, X-Spacedeck-Channel, X-Spacedeck-Spacepassword, X-Spacedeck-Auth, X-Spacedeck-Space-Auth');
|
|
res.header('Access-Control-Allow-Headers', 'Accepts, Accept-Language, Accept-Encoding, Accept-Language, Content-Type, X-Spacedeck-Space-Auth, X-Spacedeck-Space-Role, X-Spacedeck-Channel, X-Spacedeck-Spacepassword, X-Spacedeck-Auth');
|
|
res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE');
|
|
|
|
if (req.method == 'OPTIONS') {
|
|
res.sendStatus(204);
|
|
} else {
|
|
next();
|
|
}
|
|
}
|
|
|
|
module.exports = (req, res, next) => {
|
|
const origin = req.headers.origin;
|
|
|
|
if (origin) {
|
|
const parsedUrl = url.parse(origin, true, true);
|
|
|
|
// FIXME
|
|
if (parsedUrl.hostname == "cdn.spacedeck.com") {
|
|
res.header('Cache-Control', "max-age");
|
|
res.header('Expires', "30d");
|
|
res.removeHeader("Pragma");
|
|
|
|
respond(origin, req, res, next);
|
|
} else {
|
|
//Team.getTeamForHost(parsedUrl.hostname, (err, team, subdomain) => {
|
|
//if (team) {
|
|
respond(origin, req, res, next);
|
|
//} else {
|
|
next();
|
|
//}
|
|
//});
|
|
}
|
|
|
|
} else {
|
|
next();
|
|
}
|
|
}
|