diff options
| -rw-r--r-- | config.sample.js | 11 | ||||
| -rw-r--r-- | controllers/uploadController.js | 8 | ||||
| -rw-r--r-- | lolisafe.js | 6 |
3 files changed, 15 insertions, 10 deletions
diff --git a/config.sample.js b/config.sample.js index 828731e..903a97f 100644 --- a/config.sample.js +++ b/config.sample.js @@ -12,11 +12,14 @@ module.exports = { // The registered domain where you will be serving the app. Use IP if none. domains: [ - // Files will be served at https://i.kanacchi.moe/file.png - { base: 'https://i.kanacchi.moe/', prefix: ''}, + // Files will be served at http(s)://i.kanacchi.moe/Fxt0.png + { host: 'i.kanacchi.moe' }, - // Files will be served at http://localhost:9999/files/file.png - { base: 'http://127.0.0.1:9999/', prefix: 'files/'} + // Files will be served at http(s)://my.kanacchi.moe/loli-self/files/Fxt0.png + { host: 'my.kanacchi.moe', resolve: 'https://my.kanacchi.moe/loli-self/files' }, + + // Files will be served at http://localhost:9999/Fxt0.png + { domain: 'localhost:9999' } ], // Port on which to run the server diff --git a/controllers/uploadController.js b/controllers/uploadController.js index 2eccf95..6a4e5c9 100644 --- a/controllers/uploadController.js +++ b/controllers/uploadController.js @@ -56,13 +56,19 @@ uploadsController.upload = function(req, res, next){ db.table('files').insert(files).then(() => { + let basedomain = req.get('host') + '/' + for(let domain of config.domains) + if(domain.host === req.get('host')) + if(domain.hasOwnProperty('resolve')) + return basedomain = domain.resolve + '/' + res.json({ success: true, files: files.map(file => { return { name: file.name, size: file.size, - url: config.basedomain + file.name + url: basedomain + file.name } }) }) diff --git a/lolisafe.js b/lolisafe.js index 8f7b999..f360902 100644 --- a/lolisafe.js +++ b/lolisafe.js @@ -12,11 +12,7 @@ fs.existsSync('./' + config.logsFolder) || fs.mkdirSync('./' + config.logsFolder safe.enable('trust proxy') -let prefix = config.uploads.prefix -if( prefix !== '' ) - prefix = prefix + '/' - -safe.use('/' + prefix, express.static('./uploads')) +safe.use('/', express.static('./uploads')) safe.use('/', express.static('./public')) safe.use('/api', api) |